I was wondering what people think the best way is to jump to a specific page within a sharepoint list, taking into account performance considerations.


1) List with 1000 items in it

2) Each page contains 10 items

3) Show up to 10 pages at a time.

4) User can jump to any page by typing in the page number (i.e. No Next / Previous)

Here is my thinking

1) Using itemsPerPage = 10, pageNumber = ?

Use 2 Queries and a loop to find the ListItemCollectionPosition and Combine with RowLimit.


a) Get the start position

ListItemCollectionPosition positionToStart = null;

for (int i = itemsPerPage ; i < itemsPerPage * pageNumber; i + itemsPerPage)
   SPQuery.RowLimit = itemsPerPage  ;
   var spItems = SPList.GetItems(SPQuery).Items;
   if (spItems.ListItemCollectionPosition != null)
       positionToStart = spItems.ListItemCollectionPosition;

b) Get The Results

SPQuery.RowLimit = itemsPerPage;
SPQuery.ListItemCollectionPosition = positionToStart 
return SPList.GetItems(SPQuery).Items;

Any help would be great!

  • Is there a reason not to use the built in pagination on the list? Is this a custom page that needs something different? – spevilgenius Nov 1 '11 at 10:38
  • Yes, this is a custom page that requires <Previous> 1, 2, 3 ,4 <Next> – Lukie Nov 1 '11 at 21:04
  • How are you displaying the list items? Are you using a gridview or something? A regular list view can be paged so I am just trying to figure out what you are doing. – spevilgenius Nov 2 '11 at 11:15

Another way that should be considered is the "javascript way" :)

ListData.svc supports easily pagination by adding a "top" and "skip" parameter. I found more info here

You could combine the ajax call with Knockout.js or XSLT transformation to obtain the desired UI.


  • 1
    I have had a lot of success with this method. I've had Kendo UI grid controls getting data from 4 lists to build a mashup with over 3000 items in the grid (client paging) all from a dev server with 2GB RAM and a dual core processor and it took 3 seconds to get all the data. The UI responded quickly and it took about an hour to set up. – Robert Kaucher Jun 15 '13 at 3:52

As far as I know the only way you can do it is to retrieve (page number * 10) items and then only show the last 10. The ListItemCollectionPosition mechanism is completely built on the next / previous metaphor and will not work otherwise.


I did it by this way

string lastItemId = null;
int ItemsPerPage = 30; //define how many items will display on one page
int PageNumber = 3; //define page number to show result only from this page

            SPWeb curWeb = SPContext.Current.Web;
            SPListCollection lists = curWeb.Lists;
            SPList list = lists.TryGetList(ListName);

                //sorting by custom date column if needed
                string sortField = SortFieldName;
                string newDateField = SortFieldName;
                string displayDate = sortField;
                if (string.IsNullOrEmpty(sortField))
                    sortField = "ID"; 
                    newDateField = "Created";
                    displayDate = "Created";

                SPQuery query = new SPQuery();
                if (ItemsPerPage != 0)
                    query.RowLimit = (uint)ItemsPerPage;
                query.Query = "<OrderBy><FieldRef Name='" + sortField + "' Ascending='False' /></OrderBy>";

                SPListItemCollection items = null;

                for (int i = 0; i < pageNumber; ++i)
                    items = list.GetItems(query);
                    lastItemId = items.ListItemCollectionPosition.PagingInfo;

                    SPListItemCollectionPosition pos = new SPListItemCollectionPosition(lastItemId);
                    query.ListItemCollectionPosition = pos;

                foreach (SPListItem item in items)
                   //items collection has items from specific page

Also you can render page numbers on bottom of custom aspx page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.