开发者

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

开发者 https://www.devze.com 2022-12-19 10:04 出处:网络
This question already has an answer here: How to tell RadioButtonList to NOT generate a table (1 answer)
This question already has an answer here: How to tell RadioButtonList to NOT generate a table (1 answer) Closed 7 years ago.

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 = n开发者_C百科ew 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()


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号