PagedControl.ItemsPerPage Propriété

Définition

Obtient ou définit le nombre d'éléments affichés par page après la pagination. Cette API est obsolète. Pour plus d’informations sur le développement d’applications mobiles ASP.NET, consultez Applications mobiles & Sites avec 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

Valeur de propriété

Nombre d'éléments affichés par page après la pagination.

Attributs

Exemples

L’exemple de code suivant montre comment utiliser la ItemsPerPage propriété pour afficher huit éléments d’une liste de 200 éléments par page.

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

Remarques

Si la valeur est zéro, la pagination n’est pas affectée par cette propriété. Si ce n’est pas zéro, remplace les éléments affichés par page lorsque le formulaire est paginé. La valeur par défaut est zéro.

Les contrôles mobiles qui prennent en charge la pagination interne fournissent également une fonctionnalité appelée pagination personnalisée. Normalement, ces contrôles nécessitent que vous fournissiez toutes les données qu’ils peuvent afficher. Les développeurs spécifient le nombre total d’éléments figurant dans la liste de la ItemCount propriété . La ItemsPerPage propriété spécifie le nombre d’éléments affichés par page par contrôle.

S’applique à

Voir aussi