I need to dynamically create multiple RadiobuttonLists in the code behind. On top of that, certain ListItems in each RadiobuttonList should also have a textbox next to it.
E.g.
[] option1
[] option2 [TEXTBOX]
[] option3
[] option4 [TEXTBOX]
I have a SQL table which tells me each of the items to display in each RadiobuttonList, as well as whether they require a textbox.
How do I go about that in code behind?
I have this so far within a loop:
string cmd = "select * from tmpl_body_variable_options where P_NO = " + myvalue;
SqlCommand command1 = new SqlCommand(cmd, conn);
SqlDataAdapter adapter1 = new SqlDataAdapter(command1);
adapter1.Fill(dt1);
if (dt1.Rows.Count > 0)
{
for (int i = 0; i < dt1.Rows.Count; i++)
{
vivienne630
Member
1 Points
11 Posts
programmatically create Textboxes next to the RadioButtonLists
Mar 20, 2013 11:14 PM|LINK
I need to dynamically create multiple RadiobuttonLists in the code behind. On top of that, certain ListItems in each RadiobuttonList should also have a textbox next to it.
E.g.
[] option1
[] option2 [TEXTBOX]
[] option3
[] option4 [TEXTBOX]
I have a SQL table which tells me each of the items to display in each RadiobuttonList, as well as whether they require a textbox.
How do I go about that in code behind?
I have this so far within a loop:
string cmd = "select * from tmpl_body_variable_options where P_NO = " + myvalue;
SqlCommand command1 = new SqlCommand(cmd, conn);
SqlDataAdapter adapter1 = new SqlDataAdapter(command1);
adapter1.Fill(dt1);
if (dt1.Rows.Count > 0)
{
for (int i = 0; i < dt1.Rows.Count; i++)
{
radioOption.Items.Add(new ListItem(dt1.Rows[i][9].ToString(), dt1.Rows[i][8].ToString()));
}
I know there are a few threads regarding this, but all of them requires only 1 textbox (next to 'Other') and are not required to be done dynamically.
Any ideas?!
radiobuttonlist textbox
Sankalpa
Contributor
2134 Points
494 Posts
Re: programmatically create Textboxes next to the RadioButtonLists
Mar 21, 2013 04:48 AM|LINK
Hi
check this post
http://forums.asp.net/post/5330143.aspx
radiobuttonlist textbox