根据选定的下拉列表值创建动态复选框 [英] Creating a dynamic check box based on selected dropdown list value
问题描述
我想基于下拉列表中的选定值文本创建一个动态复选框.
例如:下拉列表将具有:
(test1,test2,test3),如果我是
选择Test2
它将创建一个名为test2的复选框,因此将动态创建该复选框.
此创建的复选框将具有一个并排的1个链接按钮,以及其他一些详细信息.并且在选定的下拉列表中将有5k条记录,因此仅需要的记录将创建一个复选框并提供进一步的功能
I want to create a dynamic checkbox based on selected value text from drop-downlist.
For example: The dropdownlist will have:
(test1, test2, test3) so if I am
selecting Test2
it will create a check box called test2 and so dynamically check box will get created.
this created check box will have side by 1 more linked button with few other details. and In the selected drop down list will more 5k records so whichever record wanted only will create a checkbox and go further functionalities
推荐答案
请参考此好线程
http://stackoverflow.com/questions/8383784/design-issue-in-dynamic- control-creation [^ ]
Refer this good thread
http://stackoverflow.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);
}
这篇关于根据选定的下拉列表值创建动态复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!