Bind Hashtable to DropDownList ( : DropDownList « Data Binding « ASP.Net

Bind Hashtable to DropDownList (

<%@ Page Language="VB" %>
<script runat="server">
    Dim ColorList(6) as String
    Dim FontList as new ArrayList()
    Dim QuoteList as new Hashtable()
    Sub Page_Load
      ColorList(0) = "Red"
      ColorList(1) = "Orange"
      ColorList(2) = "Yellow"
      ColorList(3) = "Green"
      ColorList(4) = "Blue"
      ColorList(5) = "Indigo"
      ColorList(6) = "Violet"
      FontList.Add("Times New Roman")
      FontList.Add("Comic Sans MS")
      QuoteList.Add ("Quotation", "Quotation. ")
      QuoteList.Add ("Joke", "Joke")
      QuoteList.Add ("Wisdom", "Wisdom")
      QuoteList.Add ("Saying", "Saying")
      If Not Page.IsPostback
        Dim ColorName as String
        For Each ColorName in ColorList
        ddlFontList.DataSource = FontList
        ddlQuoteList.DataSource = QuoteList.Keys
      End If
    End Sub
    Sub btnSelectColor_Click(sender As Object, e As EventArgs)
      lblOutputMessage.Text = QuoteList(ddlQuoteList.SelectedItem.Text)
      lblOutputMessage.ForeColor = _
      lblOutputMessage.Font.Name = _
    End Sub

    <form runat="server">
            Select a color from the list:<asp:DropDownList id="ddlColorList" runat="server"></asp:DropDownList>
            Then select a font sytle from the list: 
            <asp:DropDownList id="ddlFontList" runat="server"></asp:DropDownList>
            Finally, choose your output message: 
            <asp:DropDownList id="ddlQuoteList" runat="server"></asp:DropDownList>
            &nbsp;<asp:Button id="btnSelectColor" onclick="btnSelectColor_Click" runat="server" Text="Click here!"></asp:Button>
            <asp:Label id="lblOutputMessage" runat="server"></asp:Label>


Related examples in the same category

1.Bind Color name to asp:dropdownlist (
2.Bind DataTable to asp:DropDownList (
3.Bind ArrayList to asp:dropdownlist (
4.ArrayList Data binding for asp:DropDownList (
5.Bind arraylist elements to asp dropdown and get selected one (
6.Use ArrayList to fill dropdown value (C#)