Wednesday, May 2, 2012

Handling Large Folders and Lists : Pagination implimentaiont

Adding pagination to spQueryObject on large folder or lists



SPWeb spWebObject = SPContext.Current.Web;
SPList oList = spWebObject.Lists["Announcements"];
 
SPQuery spQueryObject = new SPQuery();
spQueryObject.RowLimit = 20;//How many results you want to display at a time it 20 now keep it //as your requirement
int currentIndex = 1;
do
{
    Response.Write("<BR>Page: " + currentIndex + "<BR>");
    SPListItemCollection spListItemsObject = oList.GetItems(spQueryObject);
 
    foreach (SPListItem oListItem in spListItemsObject)
    {
        Response.Write(SPEncode.HtmlEncode(oListItem["Title"].ToString()) +"<BR>");
    }
 
    spQueryObject.ListItemCollectionPosition = spListItemsObject.ListItemCollectionPosition;
    currentIndex++;
} while (spQueryObject.ListItemCollectionPosition != null);

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

#Intel #Core #i9 #Processors: A Breakdown

Intel Core i9 Processors: A Breakdown Intel's 14th Gen Core i9 series offers a range of processors designed for various use cases. Her...