SPListItemCollection.ListItemCollectionPosition Property
Gets an object that is used to obtain the next set of rows in a paged view of a list.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
The following example is a console application that prints list items in pages with three items per page.
using System; using Microsoft.SharePoint; namespace Test { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://localhost")) { using (SPWeb web = site.OpenWeb()) { SPList list = web.GetList("/lists/announcements"); SPQuery query = new SPQuery(); query.RowLimit = 3; // Print list items in pages with query.RowLimit items per page. int index = 1; do { SPListItemCollection items = list.GetItems(query); Console.WriteLine("\nPage: {0} Items: {1}", index, items.Count); foreach (SPListItem item in items) Console.WriteLine(item.Title); query.ListItemCollectionPosition = items.ListItemCollectionPosition; index++; } // ListItemCollectionPosition is null for the last batch. while (query.ListItemCollectionPosition != null); } } Console.ReadLine(); } } }
using Client Object Model
$0http://www.anmolrehan-sharepointconsultant.com/2011/10/client-object-model-access-large-lists.html$0
- 10/18/2011
- Rehan Anmol