Mega Code Archive

 
Categories / ASP.Net / Collections
 

DictionaryEntry working with an ArrayList

<%@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" />     <br /><br />     <b>Definition: </b>      <asp:Label id="myLabel" runat="server" text="" />   </form> </html>