The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

List Class

Renders a list of items as either a static display or an interactive list.

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

public class List : PagedControl, INamingContainer, ITemplateable, IPostBackEventHandler
public class List extends PagedControl implements INamingContainer, ITemplateable, 
public class List extends PagedControl implements INamingContainer, ITemplateable, 
Not applicable.

This control supports templated rendering by using device template sets and internal pagination. For more information, see Introduction to Device Filtering in ASP.NET and Pagination.

The following code example demonstrates how an array binds and fills a List. Notice that you can programmatically set the DataTextField and DataValueField properties of the List object.

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

<script runat="server">
    // Persist across multiple postbacks.
    private static int doneCount, schedCount, pendCount;

    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            // Set the DataMembers of the List
            List1.DataValueField = "Status";
            List1.DataTextField = "TaskName";

            // Create an ArrayList of task data
            ArrayList arr = new ArrayList();
            arr.Add(new Task("Define transactions", "scheduled"));
            arr.Add(new Task("Verify transactions", "scheduled"));
            arr.Add(new Task("Check balance sheet", "scheduled"));
            arr.Add(new Task("Compile balance sheet", "scheduled"));
            arr.Add(new Task("Prepare report", "scheduled"));
            arr.Add(new Task("Send report", "scheduled"));

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

            const string spec = "Start: {0} tasks are done, {1} " +
               "tasks are scheduled, and {2} tasks are pending.";
            Label2.Text = String.Format(spec, doneCount, +
                schedCount, pendCount);

            List1.Decoration = ListDecoration.Bulleted;

    private void Status_ItemCommand(object sender, 
        ListCommandEventArgs e)
        const string spec = "You now have {0} " + 
            "tasks done, {1} tasks scheduled, and " +
            "{2} tasks pending.";

        // Move selection to next status toward 'done'
        switch (e.ListItem.Value)
            case "scheduled":
                schedCount -= 1;
                pendCount += 1;
                e.ListItem.Value = "pending";
            case "pending":
                pendCount -= 1;
                doneCount += 1;
                e.ListItem.Value = "done";

        // Show the status of the current task
        Label1.Text = e.ListItem.Text + " is " +

        // Show current selection counts
        Label2.Text = String.Format(spec, doneCount, 
            schedCount, pendCount);

    private void Status_DataBinding(object sender, 
        ListDataBindEventArgs e)
        // Increment initial counts
        switch (e.ListItem.Value)
            case "done":
                doneCount += 1;
            case "scheduled":
                schedCount += 1;
            case "pending":
                pendCount += 1;
    // Custom class for the ArrayList items
    private class Task
        private string _TaskName;
        private string _Status;

        public Task(string taskName, string status)
            _TaskName = taskName;
            _Status = status;
        public string TaskName
            get { return _TaskName; }
        public string Status
            get { return _Status; }

<html xmlns="" >
    <mobile:form id="form1" runat="server">
        <mobile:Label ID="Label3" Runat="server">
            Click a task to change its status from 
            scheduled to pending or from pending to done:
        <mobile:List runat="server" id="List1" 
            OnItemDataBind="Status_DataBinding" />
        <mobile:Label runat="server" id="Label1" 
            ForeColor="green" Font-Italic="true" />
        <mobile:Label id="Label2" runat="server" />

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft