PagedControl.ItemWeight Property


Gets the approximate weight of a single item in the control. This API is obsolete. For information about how to develop ASP.NET mobile applications, see the Web site.

Namespace:   System.Web.UI.MobileControls
Assembly:  System.Web.Mobile (in System.Web.Mobile.dll)

protected virtual int ItemWeight { get; }

Property Value

Type: System.Int32

The approximate weight of a single item in the control.

A value of -1 indicates that the default weight for the element must be used. The inheriting class must override this property. For further information about overriding this property, see Pagination Support.

The following code example creates and uses a custom list control. The example demonstrates how to override the ItemWeight property of a List class to specify a new control weight.

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

<script runat="server">
    // A custom list control for illustration
    public class ListControl : List
        public ListControl()
            : base()

        // Set a weight for the items
        protected override int ItemWeight
            get { return 150; }

    ListControl List1;

    private void Page_Load(object sender, 
        System.EventArgs e)
        // Instantiate the custom control
        List1 = new ListControl();
        List1.ItemCount = 20;
        List1.ID = "List1";
        List1.LoadItems += this.LoadNow;

        Form1.ControlToPaginate = List1;

    // Called by the List whenever it needs new items
    private void LoadNow(object sender, 
        LoadItemsEventArgs e)
        int j = e.ItemIndex;
        // You have to estimate the item size
        int estItemSize = 110;

        // Get the optimum page weight for the device
        int wt = 
        // Get the number of items per page
        List1.ItemsPerPage = wt / estItemSize;

        // 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"));

        // Bind the array to the list
        List1.DataSource = arr;

<html xmlns="" >
    <mobile:Form id="Form1" runat="server" 
        <mobile:TextView ID="TextView1" 
            Runat="server" />

.NET Framework
Available since 1.1
Return to top