ObjectList Class
Enables you to specify multiple fields for display, per item in an object list.
public class System.Web.UI.MobileControls.ObjectList :
System.Web.UI.MobileControls.PagedControl,
System.Web.UI.INamingContainer,
System.Web.UI.MobileControls.ITemplateable,
System.Web.UI.IPostBackEventHandler
Remarks
Much of the behavior of the ObjectList control, including support for templated rendering through device template sets and internal pagination, is similar to the behavior of the List class. For more information, see the Template Sets and Templated Controls or the Pagination documentation.
Example
This example shows how to create an array of a user-defined class and then bind it to an ObjectList object when the page loads.
<%@ Page Inherits= "System.Web.UI.MobileControls.MobilePage"
Language="VB" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script language="vb" runat="server">
Public Class GroceryItem
private _department, _item, _status As String
Public Sub New( department As String, item As String, status As String)
_department = department
_item = item
_status = status
End Sub
Public ReadOnly Property Department as String
Get
Return _department
End Get
End Property
Public ReadOnly Property Item as String
Get
Return _item
End Get
End Property
Public ReadOnly Property Status as String
Get
Return _status
End Get
End Property
End Class
Public Sub Page_Load(o As Object, e As EventArgs)
If Not IsPostBack Then
Dim arr As New ArrayList()
arr.Add (New GroceryItem ("Bakery", "French Rolls", "On Sale"))
arr.Add (New GroceryItem ("Dairy", "Eggnog", "Half price"))
arr.Add (New GroceryItem ("Produce", "Apples", "A dollar a bushel"))
List1.DataSource = arr
List1.DataBind
End If
End Sub
Public Sub List1_Click(sender As Object, e As ObjectListCommandEventArgs)
If e.CommandName = "Reserve" Then
ActiveForm = Form2
ElseIf e.CommandName = "Buy"
ActiveForm = Form3
Else
ActiveForm = Form4
End If
End Sub
</script>
<mobile:Form id="Form1" runat="server" BackColor="LightBlue">
<mobile:ObjectList id="List1" runat="server"
LabelField="item"
OnItemCommand="List1_Click">
<Command Name="Reserve" Text="Reserve"/>
<Command Name="Buy" Text="Buy"/>
</mobile:ObjectList>
</mobile:Form>
<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>
<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>
<mobile:Form id="Form4" runat="server" BackColor="LightBlue">
<mobile:Label id="DefLabel" runat="server"
text="Detailed descriptions of the items will be here soon!" />
<mobile:Link id="DefLink" NavigateURL="#Form1" runat="server" text="Return" />
</mobile:Form>
[C#]
<%@ Page Inherits= "System.Web.UI.MobileControls.MobilePage"
Language="C#" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script language="c#" runat="server">
class GroceryItem
{
private String _department, _item, _status;
public GroceryItem(string department, string item, string status)
{
_department = department;
_item = item;
_status = status;
}
public String Department { get { return _department; } }
public String Item { get { return _item; } }
public String Status { get { return _status; } }
}
public void Page_Load(Object o, EventArgs e)
{
if (!IsPostBack)
{
ArrayList arr = new ArrayList();
arr.Add (new GroceryItem ("Bakery", "French Rolls", "On Sale"));
arr.Add (new GroceryItem ("Dairy", "Eggnog", "Half price"));
arr.Add (new GroceryItem ("Produce", "Apples", "A dollar a bushel"));
List1.DataSource = arr;
List1.DataBind ();
}
}
public void List1_Click(Object sender, ObjectListCommandEventArgs e)
{
if (e.CommandName == "Reserve")
{
ActiveForm = Form2;
}
else if (e.CommandName == "Buy")
{
ActiveForm = Form3;
}
else
{
ActiveForm = Form4;
}
}
</script>
<mobile:Form id="Form1" runat="server" BackColor="LightBlue">
<mobile:ObjectList id="List1" runat="server"
LabelField="item"
OnItemCommand="List1_Click">
<Command Name="Reserve" Text="Reserve"/>
<Command Name="Buy" Text="Buy"/>
</mobile:ObjectList>
</mobile:Form>
<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>
<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>
<mobile:Form id="Form4" runat="server" BackColor="LightBlue">
<mobile:Label id="DefLabel" runat="server"
text="Detailed descriptions of the items will be here soon!" />
<mobile:Link id="DefLink" NavigateURL="#Form1" runat="server" text="Return" />
</mobile:Form>
Requirements
Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile
See Also
ObjectList Control | Accessing Data