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 ......