ASP.Net/Collections/DictionaryEntry — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 15:30, 26 мая 2010

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>