简体   繁体   中英

asp:RadioButtonList add RadioButton to new line

The problem is as: I have horizontal asp:RadioButtonList, with 3 buttons witch i add programaticly C# code The thing is that the third button must be on second line. How can i do it besides creating a new asp:RadioButtonList? I have tried adding br and \\r\\n to caption but that dose not help me.

ListItem _item1 = new ListItem("1", "1");
ListItem _item2 = new ListItem("2", "2");
ListItem _item3 = new ListItem("3", "3");
rbl.Items.Add(_item1);
rbl.Items.Add(_item2);
rbl.Items.Add(_item3);

Use the RepeatColumns property ? Set it to 2 and the third one should bump down a line. This creates a column approach. Only downside to it if the labels are long it might not look right.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.repeatcolumns.aspx

If the labels are really long, then I would suggest moving to a repeater or listview and roll your own. You could use a placeholder control in the item template and in the itemdatabound event add the radio buttons based the count or index and use a mod to decide when to place a break element. Definitely a hack though.

您可以考虑使用CssAdapters,它们为调整控件布局提供了很大的灵活性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM