[我的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>
<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>
相关文章推荐
- [我的ASP.net学习历程]DataList(DataBind)(1)
- [我的ASP.net学习历程]DataBase Settion(3)
- Asp.Net学习历程
- <转>ASP.NET学习笔记之在ASP.NET MVC中使用DropDownList
- [我的ASP.net学习历程]DataList(DataBind)(2)
- [我的ASP.net学习历程]Try错误信息处理
- [我的ASP.net学习历程]DataReader(1)
- [我的ASP.net学习历程]编码转换
- [我的ASP.net学习历程]DataBase Settion(4)
- ASP.NET学习笔记--DropdownList&amp;amp;ListBox连动菜单
- [我的ASP.net学习历程]DataReader(2)
- [我的ASP.net学习历程]服务器环境检测
- [我的ASP.net学习历程]DataBase Settion(5)
- [我的ASP.net学习历程]编码转换http://www.21tx.com/dev/2004/09/21/12011.html
- ASP.NET 学习历程
- asp.net学习历程
- [我的ASP.net学习历程]Hashtable(DataBind)
- [我的ASP.net学习历程]类型转换
- [我的ASP.net学习历程]DataBase Settion(6)
- [ASP.net学习历程]调用类库函库的简单加密方法