SPListItemCollection.ListItemCollectionPosition 属性
Gets an object that is used to obtain the next set of rows in a paged view of a list.
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public ReadOnly Property ListItemCollectionPosition As SPListItemCollectionPosition
Get
用法
Dim instance As SPListItemCollection
Dim value As SPListItemCollectionPosition
value = instance.ListItemCollectionPosition
public SPListItemCollectionPosition ListItemCollectionPosition { get; }
属性值
类型:Microsoft.SharePoint.SPListItemCollectionPosition
The paging information.
备注
The ListItemCollectionPosition property returns 空引用(无 在 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.
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
Dim items As SPListItemCollection = list.GetItems(query)
Console.WriteLine(vbCrLf + "Page: {0} Items: {1}", index, items.Count)
For Each item As SPListItem In items
Console.WriteLine(item.Title)
Next
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
{
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();
}
}
}