SPListItemCollectionPosition.PagingInfo 属性
获取或设置用于生成数据的下一个页面的页面信息。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Property PagingInfo As String
Get
Set
用法
Dim instance As SPListItemCollectionPosition
Dim value As String
value = instance.PagingInfo
instance.PagingInfo = value
public string PagingInfo { get; set; }
属性值
类型:System.String
一个字符串,包含的页面信息。例如,字符串可能包含"分页 = TRUE 和 p_ID = 9",其中分页属性的值指示是否数据分页,和 ID 属性的值是在页上的最后一项的ID 。
示例
下面的示例是一个控制台应用程序,打印在页面中每页的三个项目的列表项。在每一页的结束时,该应用程序将打印用于生成数据的第二页的PagingInfo属性的值。
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();
}
}
}
备注
有关如何使用语言集成查询 (LINQ) 查询来检索SharePoint Foundation中的列表项的信息,请参阅Managing Data with LINQ to SharePoint。
另请参阅
引用
SPListItemCollectionPosition 类