1

Does anyone have an example of how to add a drop down list to the search core results web part to change the number of results?

  • You mean changing count of displayed items in paged results view? – Tomas Voracek Sep 13 '11 at 21:04
1

If you don't want to override the Core Results Web part, you can create a new one which implements the drop down values and then change the page size of the core results.

Here's an example picking the page size from the query string.

public class PageSizeWebPart : WebPart
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (HttpContext.Current.Request.QueryString["size"] == null) return;
        WebPartZoneCollection zones = this.WebPartManager.Zones;
        foreach (var core in
            (from WebPartZone zone in zones
             select zone.WebParts
             into webparts
             from WebPart webpart in webparts
             select webpart).OfType<CoreResultsWebPart>())
        {
            core.ResultsPerPage = Convert.ToInt16(HttpContext.Current.Request.QueryString["size"]);
        }
    }
}

Probably not optimal, but it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.