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

#Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc

 #Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc Linux is an open-source operating system that is loved by millio...