SPListItemCollectionPosition.PagingInfo Property
Gets or sets paging information that is used to generate the next page of data.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
<ClientCallableAttribute> _
<ClientCallableConstraintAttribute(FixedId := "PagingInfoRegEx", Type := ClientCallableConstraintType.RegularExpression, _
Value := "^$|^([-a-zA-Z0-9_\.!~\*'\(\)]{1,}[=&]{1}([-a-zA-Z0-9_\.!~\*'\(\)]|(%[A-Fa-f0-9][A-Fa-f0-9])){1,})([&=][-a-zA-Z0-9_\.!~\*'\(\)]{1,}[=&]{1}([-a-zA-Z0-9_\.!~\*'\(\)]|(%[A-Fa-f0-9][A-Fa-f0-9])){1,}){0,601}$")> _
Public Property PagingInfo As String
Get
Set
'Usage
Dim instance As SPListItemCollectionPosition
Dim value As String
value = instance.PagingInfo
instance.PagingInfo = value
[ClientCallableAttribute]
[ClientCallableConstraintAttribute(FixedId = "PagingInfoRegEx", Type = ClientCallableConstraintType.RegularExpression,
Value = "^$|^([-a-zA-Z0-9_\.!~\*'\(\)]{1,}[=&]{1}([-a-zA-Z0-9_\.!~\*'\(\)]|(%[A-Fa-f0-9][A-Fa-f0-9])){1,})([&=][-a-zA-Z0-9_\.!~\*'\(\)]{1,}[=&]{1}([-a-zA-Z0-9_\.!~\*'\(\)]|(%[A-Fa-f0-9][A-Fa-f0-9])){1,}){0,601}$")]
public string PagingInfo { get; set; }
Property Value
Type: System.String
A string that contains the paging information. For example, the string might contain “Paged=TRUE&p_ID=9”, where the value of the Paged attribute indicates whether the data is paged, and the value of the ID attribute is the ID for the last item on the page.
Examples
The following example is a console application that prints list items in pages with three items per page. At the end of each page, the application prints the value of the PagingInfo property that is used to generate the next page of data.
Imports System
Imports Microsoft.SharePoint
Module Test
Sub Main()
Using site As SPSite = New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
Dim list As SPList = web.GetList("/lists/announcements")
Dim query As SPQuery = New SPQuery()
query.RowLimit = 3
' Print list items in pages with query.RowLimit items per page.
Dim index As Integer = 1
Do
' Get a page of data.
Dim items As SPListItemCollection = list.GetItems(query)
Console.WriteLine(vbCrLf + "Page: {0} Items: {1}", index, items.Count)
' Print each item ID.
Dim item As SPListItem
For Each item In items
Console.WriteLine("Item ID = {0}", item.ID)
Next
' Print the PagingInfo string.
If Not items.ListItemCollectionPosition Is Nothing Then
Console.WriteLine(items.ListItemCollectionPosition.PagingInfo)
End If
' Set the paging information for the next page.
query.ListItemCollectionPosition = items.ListItemCollectionPosition
index = index + 1
' ListItemCollectionPosition is null for the last batch.
Loop Until query.ListItemCollectionPosition Is Nothing
End Using
End Using
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://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
{
// Get a page of data.
SPListItemCollection items = list.GetItems(query);
Console.WriteLine("\nPage: {0} Items: {1}", index, items.Count);
// Print each item ID.
foreach (SPListItem item in items)
Console.WriteLine("Item ID = {0}", item.ID);
// Print the PagingInfo string.
if (null != items.ListItemCollectionPosition)
Console.WriteLine(items.ListItemCollectionPosition.PagingInfo);
// Set the paging information for the next page.
query.ListItemCollectionPosition = items.ListItemCollectionPosition;
index++;
} // ListItemCollectionPosition is null for the last batch.
while (query.ListItemCollectionPosition != null);
}
}
Console.ReadLine();
}
}
}
Note
For information about how to use Language-Integrated Query (LINQ) queries to retrieve list items in SharePoint Foundation, see Managing Data with LINQ to SharePoint.
See Also
Reference
SPListItemCollectionPosition Class