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

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航