<%@ Page Language="C#" AutoEventWireup="True" Debug="true" %> <Script language="C#" runat="server"> void Page_Load(Object Sender,EventArgs e){ if (!IsPostBack){ Hashtable Htb=new Hashtable(); Htb.Add("1234","MicroSoft"); Htb.Add("3210","Sum"); DownList_2.DataSource=Htb; DownList_2.DataValueField="Key"; DownList_2.DataTextField="Value"; DownList_2.DataBind(); } else{ Label_1.Text="DownList_1 value is:"+DownList_1.SelectedItem.Value+"<br>"; Label_2.Text="DownList_2 value is:"+DownList_2.SelectedItem.Value+"<br>"; } } </Script> <form id="Form_1" runat="server"> DownList_1: <asp:dropdownlist ID="DownList_1" AutoPostBack="true" runat="server"> <asp:listitem Value="Default" Text="Default Colors"/> <asp:listitem Value="Bright" Text="Bright Colors"/> <asp:listitem Value="Dark" Text="Dark Colors"/> <asp:listitem Value="Mono" Text="Black and White"/> </asp:dropdownlist><br> DownList_2: <asp:dropdownlist ID="DownList_2" AutoPostBack="true" runat="server"></asp:dropdownlist> </form> <asp:label ID="Label_1" runat="server"></asp:label> <asp:label ID="Label_2" runat="server"></asp:label>
|