Accessing controls created dynamically (c#)
Posted
by Aliens
on Stack Overflow
See other posts from Stack Overflow
or by Aliens
Published on 2010-06-05T21:33:52Z
Indexed on
2010/06/05
21:42 UTC
Read the original article
Hit count: 162
In my code behind (c#) I dynamically created some RadioButtonLists with more RadioButtons in each of them. I put all controls to a specific Panel. What I need to know is how to access those controls later as they are not created in .aspx file (with drag and drop from toolbox)?
I tried this:
foreach (Control child in panel.Controls)
{
Response.Write("test1");
if (child.GetType().ToString().Equals("System.Web.UI.WebControls.RadioButtonList"))
{
RadioButtonList r = (RadioButtonList)child;
Response.Write("test2");
}
}
"test1" and "test2" dont show up in my page. That means something is wrong with this logic. Any suggestions what could I do?
© Stack Overflow or respective owner