MobileListItem Class

Represents an individual item within a List or SelectionList ASP.NET mobile control.

Note   While the class name is MobileListItem, the element name is <Item>. On a mobile page, you declare an item by using the <Item> element.

public class System.Web.UI.MobileControls.MobileListItem : 
   System.Web.UI.MobileControls.TemplateContainer,
   System.Web.UI.IStateManager

Example

Ths following examples shows how you can gain access to items in the MobileListItem object through the MobileListItemCollection class by using the selected item's index of the Items property of SelectionList class.

<%@ 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 list.
      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 SelectType.
      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.
         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

See Also

MobileListItemCollection Class | List Control | Accessing Data