动态生成DropDownList的问题.
页面上有一个按钮 bnt
点击后动态生成一个DropDownList
DropDownList ddl = new DropDownList();ddl.ID = "d1";ddl.AutoPostBack = true;ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);ddl.Items.Add(new ListItem("a","1"));ddl.Items.Add(new ListItem("b","2")); Panel1.Controls.Add(ddl)
protected void ddl_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender;Response.Write(ddl.SelectedValue); }