SPListItemCollection.ListItemCollectionPosition property

Gets an object that is used to obtain the next set of rows in a paged view of a list.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPListItemCollectionPosition ListItemCollectionPosition { get; }

Property value

Type: Microsoft.SharePoint.SPListItemCollectionPosition
The paging information.

The ListItemCollectionPosition property returns a null reference (Nothing in Visual Basic) if the number of items in the collection is fewer than the row limit for a page.

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;
                        SPListItemCollection items = list.GetItems(query);
                        Console.WriteLine("\nPage: {0}  Items: {1}", index, items.Count);

                        foreach (SPListItem item in items)

                        query.ListItemCollectionPosition = items.ListItemCollectionPosition;

                    } // ListItemCollectionPosition is null for the last batch.
                    while (query.ListItemCollectionPosition != null);