Reputation: 2560
I have many controls in same gridview cell. I am using the following code. But i want them to be displayed vertically instead of horizontally, because with the following code it assigns them in the same line. Any help?
RadioButton rd1 = new RadioButton();
rd1.Text = "Test1";
RadioButton rd2 = new RadioButton();
rd2.Text = "Test2";
grdRSM.Rows[0].Cells[2].Controls.Add(rd1);
grdRSM.Rows[0].Cells[2].Controls.Add(rd2);
Upvotes: 0
Views: 1162
Reputation: 19619
You could do two thing
First
Use RadioButtonList
instead of single RadioButton
and set it's RepeatDirection="Vertical"
Second
Use HtmlGenericControl
to render a BR
something like this
RadioButton rd1 = new RadioButton();
rd1.Text = "Test1";
RadioButton rd2 = new RadioButton();
rd2.Text = "Test2";
HtmlGenericControl br = new HtmlGenericControl("BR");
grdRSM.Rows[0].Cells[2].Controls.Add(rd1);
grdRSM.Rows[0].Cells[2].Controls.Add(br);
grdRSM.Rows[0].Cells[2].Controls.Add(rd2);
It would make those RadioButtons
to be rendered vertically
Upvotes: 2
Reputation: 639
From different line, you meant different rows??. Then please try this by replacing your last line of code.
grdRSM.Rows[1].Cells[2].Controls.Add(rd2);
Upvotes: 0