如何从占位符内的运行时表中找到控件(单选按钮) [英] how to find control(radiobutton) from runtime table inside placeholder
本文介绍了如何从占位符内的运行时表中找到控件(单选按钮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好...
我的代码如下:
hi all...
my code goes like :
RadioButton rbpres = new RadioButton();
rbpres.ID = "rbone" + increm;
rbpres.Checked = true;
rbpres.GroupName = "g1" + increm;
RadioButton rbabs = new RadioButton();
rbabs.ID = "rbtwo" + increm;
rbabs.GroupName = "g1" + increm;
tc1.Controls.Add(rbpres);
tc1.Controls.Add(rbabs);
tr.Cells.Add(tc1);
tr.Cells.Add(tc1);
tbl.Controls.Add(tr);
placeholder1.controls.add(tbl);
当我点击按钮时
我已经写过这样的代码
when am clicking button
i have written code like this
int increm = 0;
Control myControl = FindControlRecursive(PlaceHolder1, "rbone" + increm.ToString()) ;
RadioButton rbpres = this.Page.FindControl("rbone" + increm) as RadioButton;
RadioButton rbpres1 = (RadioButton)PlaceHolder1.NamingContainer.FindControl("rbone" + increm);
increm++;
and i was try to get the id of table like
Table tbl = this.Page.FindControl("attentbl") as Table;
and i got check with this
Table tbl = PlaceHolder1.FindControl("attentbl") as Table;
also same result object showing null value
但是每次显示空值时我都无法获得控件,如何获取动态单选按钮的ID
有人可以帮我吗,请你
在此先感谢
but i never get the control every time it showing null value how can i get the id of dynamic radio button
can any one help me please am begging you
thanks in advance
推荐答案
试试这个代码
Hi,
try this code
if (!IsPostBack)
{
RadioButton rdn = new RadioButton();
rdn.ID = "rdbtn";
rdn.Text = "ghgfh";
contdiv.Controls.Add(rdn);
}
Control d = contdiv.FindControl("rdbtn");
在上面的代码中,您必须使用表ID来搜索单选按钮控件.
而不是contdiv,您必须放置表格ID
最好的
In the above code,you''ve to use table id for searching radio button control.
instead of contdiv you''ve to place your table id
All the Best
这篇关于如何从占位符内的运行时表中找到控件(单选按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文