【发布时间】:2014-01-28 22:54:56
【问题描述】:
我们有一个在服务器端生成的列表,然后使用<asp:RadioButtonList... 显示它。
但是,我们如何在其中一项之后添加一些 HTML?
这个想法是,如果生成其中一个,就会生成一些“子”单选按钮。
谢谢
ASP.NET:
private void PopulateFollowUpRadioButtons(Order order)
{
//Based on the options selected while creating the order template populate the radio button list.
if (order.OrderTemplate.fur01Visible)
FolloupRadioButtonList.Items.Add(new ListItem(order.OrderTemplate.fur01Label, "1"));
if (order.OrderTemplate.fur02Visible)
FolloupRadioButtonList.Items.Add(new ListItem(order.OrderTemplate.fur02Label, "2"));
if (order.OrderTemplate.fur03Visible)
FolloupRadioButtonList.Items.Add(new ListItem(order.OrderTemplate.fur03Label, "3"));
//If follow up option is already selected then select the option in the Follow Up Radio button control
if (order.FollowUpRoleId != null)
FolloupRadioButtonList.SelectedValue = order.FollowUpRoleId.Value.ToString();
}
<asp:RadioButtonList ID="FolloupRadioButtonList" CssClass="black" ForeColor="Black" runat="server"></asp:RadioButtonList>
【问题讨论】:
-
粘贴您目前拥有的内容。
-
@Esa 粘贴了上面的代码。
-
如果你需要层次结构,也许 RadioButtonList 不是最好的方法。树或自定义用户控件可能是更好的选择
标签: asp.net