This documentation is archived and is not being maintained.

ObjectList Class

Enables you to specify multiple fields for display, per item in an object list.

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

Public Class ObjectList
	Inherits PagedControl
	Implements INamingContainer, ITemplateable, IPostBackEventHandler
Dim instance As ObjectList

public class ObjectList extends PagedControl implements INamingContainer, ITemplateable, 
public class ObjectList extends PagedControl implements INamingContainer, ITemplateable, 
Not applicable.

Much of the behavior of the ObjectList, including support for templated rendering through device template sets and internal pagination, is similar to the behavior of the List. For more information, see the Introduction to the ObjectList Control or the Pagination documentation.

The following code example demonstrates how to create an array of a user-defined class and then bind it to an ObjectList object when the page loads. It also shows how the list and details views display the commands. For this example, there is also a button that displays a form with a list of all the fields using the AllFields property.


The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information, see ASP.NET Web Page Code Model.

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

<script runat="server">
    Dim bakeryCount, dairyCount, produceCount As Integer

    Private Sub Page_Load(ByVal o As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            ' Create an array and bind it to the list
            Dim arr As New ArrayList()
            arr.Add(New GroceryItem _
                ("Bakery", "Rolls", "On Sale"))
            arr.Add(New GroceryItem _
                ("Dairy", "Eggnog", "Half price"))
            arr.Add(New GroceryItem _
                ("Produce", "Apples", _
                "A dollar a bushel"))
            arr.Add(New GroceryItem _
                ("Bakery", "Bread", "On Sale"))

            List1.DataSource = arr

            ' To show only one field on opening page,
            ' comment the next line
            List1.TableFields = "Item;Department"
            List1.LabelField = "Department"

            ' Display a report after items are databound
            Const txt As String = "Number of items by Department<br>Produce: " + _
                "{0}<br />Dairy: {1}<br />Bakery: {2}"
            TextView2.Text = String.Format(txt, produceCount, dairyCount, bakeryCount)
        End If
    End Sub

    ' Command event for buttons
    Private Sub List1_Click(ByVal sender As Object, _
        ByVal e As ObjectListCommandEventArgs)

        If e.CommandName = "Reserve" Then
            ActiveForm = Form2
        ElseIf e.CommandName = "Buy" Then
            ActiveForm = Form3
            ActiveForm = Form4
        End If
    End Sub

    ' Count items in each department
    Private Sub List1_ItemDataBind(ByVal sender As Object, ByVal e As ObjectListDataBindEventArgs)
        Select Case CType(e.DataItem, GroceryItem).Department
            Case "Bakery"
                bakeryCount += 1
            Case "Dairy"
                dairyCount += 1
            Case "Produce"
                produceCount += 1
        End Select
    End Sub

    Private Sub AllFields_Click(ByVal sender As Object, ByVal e As EventArgs)

        ActiveForm = Form5
        Dim spec As String = "{0}: {1}<br/>"
        Dim flds As IObjectListFieldCollection = List1.AllFields
        Dim i As Integer
        For i = 0 To flds.Count - 1
            TextView1.Text += _
                String.Format(spec, (i + 1), flds(i).Title)
    End Sub

    ' Structure for ArrayList records
    Private Class GroceryItem
        ' A private class for the Grocery List
        Private _department, _item, _status As String
        Public Sub New(ByVal department As String, _
            ByVal item As String, ByVal status As String)
            _department = department
            _item = item
            _status = status
        End Sub
        Public ReadOnly Property Department() As String
                Return _department
            End Get
        End Property
        Public ReadOnly Property Item() As String
                Return _item
            End Get
        End Property
        Public ReadOnly Property Status() As String
                Return _status
            End Get
        End Property
    End Class

<html xmlns="" >
    <mobile:Form id="Form1" runat="server" BackColor="LightBlue">
        <mobile:ObjectList id="List1" runat="server" 
            OnItemCommand="List1_Click" OnItemDataBind="List1_ItemDataBind">
            <DeviceSpecific ID="DeviceSpecific1" Runat="server">
                <!-- See Web.config for filters -->
                <Choice Filter="isWML11" CommandStyle-Font-Bold="NotSet" />
                <Choice CommandStyle-Font-Bold="true" 
                    CommandStyle-Font-Name="Arial" />
            <Command Name="Reserve" Text="Reserve" />
            <Command Name="Buy" Text="Buy" />
        <mobile:Command ID="AllFieldsCmd" Runat="server" 
            List All Fields</mobile:Command>
        <mobile:TextView ID="TextView2" Runat="server" />
    <mobile:Form id="Form2" runat="server" BackColor="LightBlue">
        <mobile:Label id="ResLabel" runat="server"
            text="Sale item reservation system coming soon!" />
        <mobile:Link id="ResLink" NavigateURL="#Form1" 
            runat="server" text="Return" />
    <mobile:Form id="Form3" runat="server" BackColor="LightBlue">
        <mobile:Label id="BuyLabel" runat="server"
            Text="Online purchasing system coming soon!" />
        <mobile:Link ID="BuyLink" NavigateURL="#Form1" 
            Runat="server" text="Return" />
    <mobile:Form id="Form4" Runat="server" BackColor="LightBlue">
        <mobile:Label ID="DefLabel" Runat="server" 
             Text="Detailed item descriptions will be here soon!"/>
        <mobile:Link ID="DefLink" NavigateURL="#Form1" 
            Runat="server" Text="Return" />
    <mobile:Form ID="Form5" Runat="server">
        <mobile:Label ID="Label1" Runat="server">
            List of AllFields:</mobile:Label>
        <mobile:TextView ID="TextView1" Runat="server" />
        <mobile:Link ID="Link1" Runat="server" NavigateUrl="#Form1" 

This is a sample Web.config file with several device specific filters.

    <compilation debug="true" />
    <authentication mode="Windows" />
    <customErrors mode="Off" />
    <httpRuntime useFullyQualifiedRedirectUrl="true" />
    <mobileControls cookielessDataDictionaryType="System.Web.Mobile.CookielessData" />

      <!-- Only a few filters are provided here -->
      <filter name="isJPhone" compare="Type" argument="J-Phone" />
      <filter name="isHTML32" compare="PreferredRenderingType" argument="html32" />
      <filter name="isWML11" compare="PreferredRenderingType" argument="wml11" />


  • AspNetHostingPermission  for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
  • AspNetHostingPermission  for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.

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