Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
You mean changing count of displayed items in paged results view? –  Tomas Voracek Sep 13 '11 at 21:04

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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