【问题标题】:How to select just one option in RadioButtonList within a repeater with postback如何在带有回发的转发器中仅选择 RadioButtonList 中的一个选项
【发布时间】:2016-05-21 03:50:44
【问题描述】:

我在Repeater 中有一个RadioButtonList,我想一次只选择一个选项。但是对于动态创建的每个 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>

【问题讨论】:

    标签: c# asp.net repeater radiobuttonlist


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,这个链接有解决方案,帖子的第二个答案是正确的。非常感谢。
    猜你喜欢
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-24
    相关资源
    最近更新 更多