Bind Color name to asp:dropdownlist ( : DropDownList « Data Binding « ASP.Net

Bind Color name to asp:dropdownlist (

<%@ Page Language="VB" %>
   <title>Collection DataBinding Example</title>
   <script runat="server">
      Dim FontColor As String
      Sub Page_Load()
         If Not IsPostBack Then
            Dim Colors As New ArrayList()
            Color.DataSource = Colors
            Color.SelectedIndex = 0
         End If
         Output.Text = "The value for FontColor is " & _
            Color.SelectedItem.Value & "."
         Output.ForeColor = System.Drawing.Color.FromName(Color.SelectedItem.Value)
         End Sub
   <h1>Collection DataBinding Example</h1>
   <form runat="server">
      Choose a color from the list for the font color:
      <asp:dropdownlist id="Color" autopostback="True" runat="server"/>
      <asp:label id="Output" runat="server"/>

Related examples in the same category

1.Bind DataTable to asp:DropDownList (
2.Bind ArrayList to asp:dropdownlist (
3.Bind Hashtable to 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#)