如何在具有回发的转发器中的RadioButtonList中仅选择一个选项

时间:2016-05-20 19:11:31

标签: c# asp.net repeater radiobuttonlist

RadioButtonList内有Repeater,我想一次只选一个选项。但是对于动态创建的每个 RadioButtonList ,我可以在每个 RadioButtonList 中选择多个选项。

如何选择一个选项并停用之前的选项?

<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="ItemBound">
    <ItemTemplate>
        <h4><label id="header" runat="server"><%# Eval("Description") %></label></h4>
        <asp:UpdatePanel ID="panel" runat="server">
            <ContentTemplate>
                <asp:RadioButtonList ID="rdo" RepeatDirection="Vertical" runat="server" OnSelectedIndexChanged="rdo_SelectedIndexChanged" AutoPostBack="true" ClientIDMode="AutoID"></asp:RadioButtonList>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
    </ItemTemplate>
</asp:Repeater>

1 个答案:

答案 0 :(得分:0)

当控件在列表绑定控件中呈现时,ID将更改为唯一,以便JavaScript可以使用它。这里有一个很棒的论坛帖子,它包括一个解决方法。

http://forums.asp.net/t/1378112.aspx?RadioButtonList+in+a+Repeater+GroupName