ASP.NET动态创建DropDownList,的SelectedIndexChange事件触发后,连原先的DropDownList都消失掉
我通过后台动态创建了个DropDownList,但添加了个SelectedIndexChange事件,然后,把AutoPostBack设置为true,当,我改变DropD...
我通过后台动态创建了个DropDownList,但添加了个SelectedIndexChange事件,然后,把AutoPostBack设置为true,当,我改变DropDownList选项的时候,DropDownList消失掉了.。我的源码: public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList ddlControl = new DropDownList(); ddlControl.ID = "ddlEx"; ddlControl.AutoPostBack = true; ddlControl.SelectedIndexChanged += new EventHandler(ddlEx_SelectedIndexChanged); ddlControl.Items.Insert(0, new ListItem("Please choose", "-1")); ddlControl.Items.Insert(1, new ListItem("Please choose1", "0")); ddlControl.Visible = true; pan.Controls.Add(ddlControl); } } protected void ddlEx_SelectedIndexChanged(object sender, EventArgs e) { TextBox tbxControl = new TextBox(); tbxControl.ID = "tbxEx"; } }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询