Classe MobileListItem

Rappresenta un singolo elemento all'interno di un controllo mobile ASP.NET List o SelectionList.

Nota   Il nome della classe è MobileListItem, mentre il nome dell'elemento è <Item>. In una pagina mobile, un elemento viene dichiarato mediante l'elemento <Item>.

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

Esempio

Gli esempi che seguono mostrano come sia possibile accedere agli elementi dell'oggetto MobileListItem mediante la classe MobileListItemCollection utilizzando l'indice dell'elemento selezionato della proprietà Items della classe SelectionList.

<%@ 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>

Requisiti

Spazio dei nomi: System.Web.UI.MobileControls

Assembly: System.Web.Mobile

Vedere anche

Classe MobileListItemCollection | Controllo List | Accesso ai dati