我有带动态下拉控件的asp.net页面,我只需要为用户选择启动selectedIndexchanged
事件。
目前selectedIndexchanged
事件正在为每个编程选择更改而触发。
有人可以建议如何检查/触发selectedIndexchanged
事件只选择“用户”吗?
答案 0 :(得分:0)
我希望这对你有用
protected void Page_Load(object sender, System.EventArgs e){
DropDownList cbTest = new DropDownList();
cbTest.ID = "cbot";
//create an event handler for the SelectedIndexChanged event
cbTest.SelectedIndexChanged += new EventHandler(cbt_SelectedIndexChanged);
cbTest.Items.Add("1");
cbTest.Items.Add("2");
cbTest.Items.Add("3");
//set the AutoPostBack property to sends the data back to the server
cbTest.AutoPostBack = true;
this.form1.Controls.Add(cbTest);
}
//handle the selections made by the User
void cbt_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("This works");
}