且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

根据选定的下拉列表值创建动态复选框

更新时间:2022-12-03 17:32:42

请参考此好线程
http://***.com/questions/8383784/design-issue-in-dynamic- control-creation [^ ]
Refer this good thread
http://***.com/questions/8383784/design-issue-in-dynamic-control-creation[^]


嘿,根据您的要求,您可以更改以下代码

将占位符放到您希望复选框出现的位置,

设置dropdown的Autopostback属性= true

然后将以下代码(仅用于示例)添加到您选择的索引更改的事件中

Hey based on your requirement you can change the below code

Drop a Place holder where u want the checkbox to appear ,

Set Autopostback property of dropdown =true

and then add the below code (for sample only) to you selectedindex changed event

protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
 {
     CheckBox chk = new CheckBox();
     chk.Checked = false;
     chk.Text = DropDownList2.SelectedItem.Text;
     PlaceHolder1.Controls.Add(chk);
 }