Search This Blog

Wednesday, June 30, 2010

Paging through SharePoint list items with SPQuery

SPQuery query = new SPQuery();
query.RowLimit = 10; // that is our page size
do
{
SPListItemCollection items = SPContext.Current.List.GetItems(query);
// do something with the page result
// set the position cursor for the next iteration
query.ListItemCollectionPosition = items.ListItemCollectionPosition;
} while (query.ListItemCollectionPosition != null)

No comments:

Post a Comment