J
Jacob
Hi,
Someone please clear this for me!
I display a bunch of button controls on a page dynamically, adding them to a
placeholder control in my .aspx. I have a button with a on_click event that
is suppose to grab the values from those dynamic controls.
I create the controls like so:
RadioButton _rb = null;
for(int x = 0; x <= 5; x++)
{
_rb = new RadioButton();
_rb.GroupName = "group1";
_rb.Text = "label#" + x;
ph.Controls.Add(_rb);
ph.Controls.Add(new LiteralControl("<br>"));
}
And the button event that is too grab the values from the dynamically
created controls:
public void btn_Click(object sender, EventArgs e)
{
Response.Write("<br>Button Clicked!<br>");
RadioButton _rb = null;
for(int x = 0; x <= 5; x++)
{
_rb = new RadioButton();
_rb.GroupName = "group1";
_rb.Text = "label#" + x;
Response.Write("<br>Label#" + x + "is checked=" + _rb.Checked + "<br>");
}
}
What is the best practise for this?
------------------------------------------------
..Net Resources
http://www.asp.net
http://www.aspalliance.com
http://www.csharpfriends.com
http://www.dotnetjunkies.com
http://www.aspadvice.com
http://www.msdn.com
http://weblogs.asp.net
------------------------------------------------
Someone please clear this for me!
I display a bunch of button controls on a page dynamically, adding them to a
placeholder control in my .aspx. I have a button with a on_click event that
is suppose to grab the values from those dynamic controls.
I create the controls like so:
RadioButton _rb = null;
for(int x = 0; x <= 5; x++)
{
_rb = new RadioButton();
_rb.GroupName = "group1";
_rb.Text = "label#" + x;
ph.Controls.Add(_rb);
ph.Controls.Add(new LiteralControl("<br>"));
}
And the button event that is too grab the values from the dynamically
created controls:
public void btn_Click(object sender, EventArgs e)
{
Response.Write("<br>Button Clicked!<br>");
RadioButton _rb = null;
for(int x = 0; x <= 5; x++)
{
_rb = new RadioButton();
_rb.GroupName = "group1";
_rb.Text = "label#" + x;
Response.Write("<br>Label#" + x + "is checked=" + _rb.Checked + "<br>");
}
}
What is the best practise for this?
------------------------------------------------
..Net Resources
http://www.asp.net
http://www.aspalliance.com
http://www.csharpfriends.com
http://www.dotnetjunkies.com
http://www.aspadvice.com
http://www.msdn.com
http://weblogs.asp.net
------------------------------------------------