共用方式為


SPListItemCollection.ListItemCollectionPosition property

取得用來取得下一個資料列集的分頁檢視的清單中的物件。

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

Syntax

'宣告
Public ReadOnly Property ListItemCollectionPosition As SPListItemCollectionPosition
    Get
'用途
Dim instance As SPListItemCollection
Dim value As SPListItemCollectionPosition

value = instance.ListItemCollectionPosition
public SPListItemCollectionPosition ListItemCollectionPosition { get; }

Property value

Type: Microsoft.SharePoint.SPListItemCollectionPosition
分頁的資訊。

備註

如果集合中的項目數目是少於一頁的資料列限制, ListItemCollectionPosition屬性會傳回a null reference (Nothing in Visual Basic) 。

Examples

下列範例是一個主控台應用程式,列印清單的項目在網頁中每一頁的三個項目。

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();
        }
    }
}

請參閱

參照

SPListItemCollection class

SPListItemCollection members

Microsoft.SharePoint namespace

ListItemCollectionPosition