ASP.Net/Collections/DictionaryEntry

Материал из .Net Framework эксперт
Версия от 14:51, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

DictionaryEntry working with an ArrayList

   <source lang="csharp">

<%@Page language="vb" debug="true"  %> <script runat="server" language="vb">

 Sub Page_Load(Source As Object, E as EventArgs)
   Dim mySortedList as new SortedList
   Dim Item As DictionaryEntry
   
   mySortedList("A")="AA"
   mySortedList("B")="BB"
   mySortedList("C")="CC"
   mySortedList("D")="DD"
   If Not Page.IsPostback
     For Each Item In mySortedList
       Dim newListItem As new ListItem()
       newListItem.Text = Item.Key
       newListItem.Value = Item.Value
       myDropDownList.Items.Add(newListItem)
     Next
   End If
 End Sub
 Sub Click(Source As Object, E as EventArgs)
   myLabel.Text = myDropDownList.SelectedItem.Value
 End Sub

</script> <html>

 <form runat="server">
   Pick a word from the list:
   <asp:dropdownlist id="myDropDownList" runat="server" />
   <asp:button id="myButton" runat="server" text="OK" Onclick="Click" />
   

Definition: <asp:Label id="myLabel" runat="server" text="" /> </form>

</html>

      </source>