WebHosting

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

How to Enable and Configure Remote Desktop (RDP) on Ubuntu 24.04.4 LTS

Remote Desktop Protocol (RDP) support in Ubuntu has become considerably easier with the GNOME Remote Desktop stack included in modern Ubuntu...