[英]How Clear, Deselect or Uncheck Dynamic Radio Buttons List?(ASP.NET, C#)
I created Radio Buttons List of dynamic way. 我创建了单选按钮列表的动态方式。 Using HTML tags, I employed the DIV tag in a couple of RadioButtons, this leave one choice or one election (working like a GroupBox).
使用HTML标签,我在几个RadioButtons中使用了DIV标签,这留下了一个选择或一个选择(就像GroupBox一样工作)。 Also, I created a Clean Button that going to clean or deselect the RadioButtons List.
另外,我创建了一个清理按钮,用于清理或取消选择单选按钮列表。 I proved that use of Clean() method not works.
我证明使用Clean()方法不起作用。 And using the ID of Radio (equals to "false") also not works.
并且使用Radio的ID(等于“ false”)也不起作用。 Por example:
例如:
protected void btnLimpiar_Click(object sender, EventArgs e){
this.RadioButtonList0_1.Checked = false;}
I need know how to clean these dynamic controls that were created through consult in SQL. 我需要知道如何清除这些通过SQL中的咨询创建的动态控件。 Here genre the Radio Buttons list:
在此流派单选按钮列表:
foreach (DataRow drCurrent in objDataTable.Rows){
HtmlGenericControl createDiv = new HtmlGenericControl("div");
createDiv.ID = "divA" + i;
createDiv.Style.Add("float", "left");
createDiv.Style.Add("padding", "2%");
RBL = new RadioButtonList();
RBL.ID = "RadioButtonList" + i.ToString(); ;
RBL.RepeatDirection = RepeatDirection.Horizontal;
RBL.Items.Add("Si");
RBL.Items.Add("No");
RBL.Items[0].Selected = false;
createDiv.Controls.Add(RBL);
i += 1;
}
The previous, works successful. 以前,工作成功。 But ¿What is the method, function or code that make this action?
但是,执行此操作的方法,功能或代码是什么? However, I used a list that count and then search each RadioButtonList and deselect it.
但是,我使用了一个计数列表,然后搜索每个RadioButtonList并取消选择它。
foreach (RadioButtonList L_RBL in RBL.Items)
{
RBL.Items.Clear();
L_RBL.ClearSelection();
}
And not working :( Thanks for all. 而且不工作:(谢谢大家。
RBL shouldn't contain any RadioButtonList objects, as it is itself RadioButtonList. RBL不应包含任何RadioButtonList对象,因为它本身就是RadioButtonList。 It will contain radio buttons.
它将包含单选按钮。
I found this question while looking for help on a similar issue. 我在寻找类似问题的帮助时发现了这个问题。 This should work to clear the selections on your RBL:
这应该可以清除RBL上的选择:
RBL.ClearSelection();
使用此行代码
RadioButtonList1.SelectIndex = -1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.