PagedControl.ItemsPerPage Vlastnost

Definice

Získá nebo nastaví počet položek zobrazených na stránce po stránkování. Toto rozhraní API je zastaralé. Informace o vývoji ASP.NET mobilních aplikací najdete v tématu Mobilní aplikace & weby s ASP.NET.

public:
 property int ItemsPerPage { int get(); void set(int value); };
[System.ComponentModel.Bindable(true)]
public int ItemsPerPage { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.ItemsPerPage : int with get, set
Public Property ItemsPerPage As Integer

Hodnota vlastnosti

Počet položek zobrazených na stránce po stránkování

Atributy

Příklady

Následující příklad kódu ukazuje, jak pomocí ItemsPerPage vlastnosti vykreslit osm položek ze seznamu 200 položek na stránku.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    // Called by the List whenever it needs new items
    private void LoadNow(object sender, LoadItemsEventArgs e)
    {
        int j = e.ItemIndex;
        int estItemSize = 110;

        // Get the optimum page weight for the device
        int wt = Form1.Adapter.Page.Adapter.OptimumPageWeight;
        // Get the number of items per page
        List1.ItemsPerPage = wt / estItemSize;
 
        // Clear the current items
        List1.Items.Clear();

        // Build a section of the array
        ArrayList arr= new ArrayList();
        for (int i = 1; i <= e.ItemCount; i++)
        {
            int v = i + j;
            arr.Add((v.ToString() + " List Item"));
        }

        // Assign the array to the list
        List1.DataSource = arr;
        List1.DataBind();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:Form id="Form1" runat="server" Paginate="true">
        <mobile:List id="List1" runat="server" 
            ItemCount="200" onLoadItems="LoadNow" />
    </mobile:Form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    ' Called by the List whenever it needs new items
    Private Sub LoadNow(ByVal sender As Object, _
        ByVal e As LoadItemsEventArgs)
        
        Dim i, j As Integer
        i = 0
        j = e.ItemIndex
        Dim estItemSize As Integer = 110

        ' Get the optimum page weight for the device
        Dim wt As Integer = _
            form1.Adapter.Page.Adapter.OptimumPageWeight
        ' Get the number of items per page
        List1.ItemsPerPage = wt / estItemSize

        ' Clear the current items
        List1.Items.Clear()
        
        ' Build a section of the array
        Dim arr As New ArrayList()
        For i = 1 To e.ItemCount
            arr.Add(j + i)
        Next
        
        ' Assign the array to the list
        List1.DataSource = arr
        List1.DataBind()
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:form id="form1" runat="server" Paginate="true">
        <mobile:List id="List1" runat="server" 
            ItemCount="200" onLoadItems="LoadNow" 
            ItemsPerPage="8" />
    </mobile:form>
</body>
</html>

Poznámky

Pokud nula, stránkování není touto vlastností ovlivněno. Pokud není nenulový, přepíše položky zobrazené na stránce, pokud je formulář stránkovaný. Výchozí hodnota je nula.

Mobilní ovládací prvky, které podporují interní stránkování, také poskytují funkci označovanou jako vlastní stránkování. Tyto ovládací prvky obvykle vyžadují, abyste poskytli všechna data, která mohou zobrazit. Vývojáři určují celkový počet položek, které jsou v seznamu ve ItemCount vlastnosti . Vlastnost ItemsPerPage určuje, kolik položek ovládací prvek zobrazí na stránce.

Platí pro

Viz také