How to override Core Results Web Part's limit of 50 results per page?

By default "Core Results Web Part" can result a maximum of 50 results. But grouping results require as many items as per requirement. To achieve this, we need to create our own CoreResults Web Part. The following code snippet help to achieve that.


public class cvsearch : CoreResultsWebPart
    {
        protected override XPathNavigator GetXPathNavigator(string viewPath)
        {
            QueryManager queryManager = SharedQueryManager.GetInstance(Page).QueryManager;
            queryManager[0].ItemsPerPage = 100;
            XmlDocument xmlDocument = queryManager.GetResults(queryManager[0]);
            return xmlDocument.CreateNavigator();
        }
    }

3 comments:

  1. Hi ,

    I implemented the above code. but it is not working for me ..still taking the web part property of 10 results per page. Please help

    ReplyDelete
  2. I do have the same issue can anybody help tried the same above solution but not working

    ReplyDelete
  3. For everyone who has problems with the code:
    QueryManager queryManager = SharedQueryManager.GetInstance(Page, QueryNumber).QueryManager;
    queryManager[0][0].ItemsPerPage = 1000;
    XmlDocument xmlDocument = queryManager[0][0].GetResults(queryManager);
    return xmlDocument.CreateNavigator();

    ReplyDelete