MobileListItemCollection Class
Represents a collection of MobileListItem objects, and is used to hold the items of a List control and a SelectionList control.
public class System.Web.UI.MobileControls.MobileListItemCollection :
ArrayListCollectionBase, IStateManager
Remarks
Accessing the Items property of a List control or the Items property of a SelectionList control retrieves a MobileListItemCollection object. You can add or remove items from the collection at run time.
A MobileListItemCollection object inherits from the System.Collections.ICollection interface.
Example
This example displays the value of a text property of the selected item from the MobileListItemCollection of the SelectionList1 object.
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="c#" %>
<script language="c#" runat="server">
public void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
Label1.Text = "Pick an item";
// Create and fill an array.
ArrayList values = new ArrayList();
values.Add("one");
values.Add("two");
values.Add("three");
// Bind the array to the list.
SelectionList1.DataSource = values;
SelectionList1.DataBind();
// Set the value of the SelectType property.
SelectionList1.SelectType =
System.Web.UI.MobileControls.ListSelectType.Radio;
}
else
{
if (SelectionList1.SelectedIndex > -1)
{
// To show the selection, get the Selection property.
Label1.Text = "You have selected " + SelectionList1.Selection;
// This is an alternate means of showing the selection by using
// the MobileListItemCollection object.
Label2.Text = "You have selected "
+ SelectionList1.Items[SelectionList1.SelectedIndex].Text;
}
else
{
Label1.Text = "No items selected";
}
}
}
</script>
<mobile:Form id="Form1" runat="server">
<mobile:Label id="Label1" runat="server" Text="Show a list" />
<mobile:Label runat="server" id="Label2" />
<mobile:SelectionList runat="server" id="SelectionList1" />
<mobile:Command runat="server" Text="Ok" />
</mobile:Form>
Requirements
Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile