net2:DropDownList的使用
原文发布时间为:2008-07-29 —— 来源于本人的百度文章 [由搬家工具导入]
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.Items.Add("sf");
DropDownList1.Items.Add("nv");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Items.Add(TextBox1.Text);
}
protected void Button1_Command(object sender, CommandEventArgs e)
{
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
switch (DropDownList2.SelectedValue)//要把AUTOPOSTBACK变成true属性
{
case "a":
Label1.Text = "1";
break;
case "b":
Label1.Text = "2";
break;
case "c":
Label1.Text = "3";
break;
}
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked)
{
Label2.Text = "xuan zhong";
}
else
{
Label2.Text = "wei xuan zhong";
}
}
}