Share via


PagedControl.ItemsPerPage Propriedade

Definição

Obtém ou define o número de itens exibidos por página depois da paginação. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com 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

Valor da propriedade

O número de itens exibidos por página após a paginação.

Atributos

Exemplos

O exemplo de código a seguir mostra como usar a ItemsPerPage propriedade para renderizar oito itens de uma lista de 200 itens por página.

<%@ 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>

Comentários

Se zero, a paginação não será afetada por essa propriedade. Se diferente de zero, substitui os itens exibidos por página quando o formulário é paginado. O valor padrão é zero.

Os controles móveis que dão suporte à paginação interna também fornecem um recurso chamado paginação personalizada. Normalmente, esses controles exigem que você forneça todos os dados que eles podem exibir. Os desenvolvedores especificam o número total de itens que estão na lista na ItemCount propriedade . A ItemsPerPage propriedade especifica quantos itens o controle exibe por página.

Aplica-se a

Confira também