CSDN博客

img bgu

[我的ASP.net学习历程]DropDownList

发表于2004/9/21 19:54:00  714人阅读

分类: [My ASP/ASP.net(C#)]

<%@ 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>
0 0

相关博文

我的热门文章

img
取 消
img