您的位置:首页 > 编程语言 > ASP

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

2004-09-21 19:54 393 查看
<%@ 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: