PagedControl.ItemsPerPage Свойство

Определение

Получает или задает число элементов, отображаемых на каждой странице, после разбиения на страницы. Этот API устарел. Сведения о разработке ASP.NET мобильных приложений см. в статье Мобильные приложения & сайты с 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

Значение свойства

Число элементов, отображаемых на каждой странице, после разбиения на страницы.

Атрибуты

Примеры

В следующем примере кода показано, как использовать ItemsPerPage свойство для отрисовки восьми элементов списка из 200 элементов на странице.

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

Комментарии

Если значение равно нулю, это свойство не влияет на разбиение на страницы. Если значение не равно нулю, переопределяет элементы, отображаемые на странице при разбиении формы на страницы. Значение по умолчанию равно нулю.

Мобильные элементы управления, поддерживающие внутреннее разбиение на страницы, также предоставляют функцию, называемую пользовательским разбиением на страницы. Как правило, такие элементы управления требуют предоставления всех данных, которые они могут отображать. Разработчики указывают общее количество элементов, которые находятся в списке, в свойстве ItemCount . Свойство ItemsPerPage указывает, сколько элементов отображает элемент управления на странице.

Применяется к

См. также раздел