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

<%@ 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值