How can I prevent asp:RadioButtonList from rendering a HTML-Table? [duplicate]
Asked Answered
H

2

9

I would like to render a simple list of - Controls. My ASP.NET Code-behind looks like:

RadioButtonList list = new RadioButtonList();
                    list.ID = rbl.name;
                    list.CssClass = rbl.cssClass;

                    foreach (radio radio in rbl.radio)
                    {
                        ListItem li = new ListItem();
                        li.Text = radio.label;
                        li.Value = radio.value;
                        li.Selected = radio.@checked;
                        list.Items.Add(li);

                    }

But the RadioButtonList renders automatically a HTML-Table. If I use HtmlInputRadioButton everything works fine but it crashes on RenderControl()

Harlem answered 2/2, 2010 at 12:9 Comment(0)
B
30

You should take a look into RadioButtonList.RepeatLayout Property

Use this property to specify whether the items in the RadioButtonList control are displayed in a table. If this property is set to RepeatLayout.Table, the items in the list are displayed in a table. If this property is set to RepeatLayout.Flow, the items in the list are displayed without a table structure.

Brainstorming answered 2/2, 2010 at 12:12 Comment(2)
Thanks a lot. This is the fastest perfect answer I've ever seen.Harlem
I would like the label to wrap around the checkboxGribble
B
3

Adding to the answer by Rubens Farias, ASP.NET 4 adds two new options to RadioButtonList.RepeatLayout, OrderedList and UnorderedList.

Belief answered 21/8, 2012 at 3:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.