Classe MobileListItemCollection

Rappresenta un insieme di oggetti MobileListItem e viene utilizzata per contenere gli elementi di un controllo List e di un controllo SelectionList.

public class System.Web.UI.MobileControls.MobileListItemCollection : 
   ArrayListCollectionBase, IStateManager

Osservazioni

L'accesso alla proprietà Items di un controllo List o alla proprietà Items di un controllo SelectionList consente di recuperare un oggetto MobileListItemCollection. È possibile aggiungere o rimuovere elementi dall'insieme in fase di esecuzione.

Un oggetto MobileListItemCollection eredita dall'interfaccia System.Collections.ICollection.

Esempio

In questo esempio viene mostrato il valore di una proprietà di testo dell'elemento selezionato da MobileListItemCollection dell'oggetto SelectionList1.

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

Requisiti

Spazio dei nomi: System.Web.UI.MobileControls

Assembly: System.Web.Mobile