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

OBS Browser Source Not Working? How to Interact With Web Pages Inside OBS Studio

If you're using OBS Studio to display a website, YouTube page, dashboard, live poll, chat widget, or web application, you may notice so...