简体   繁体   中英

How to select just one option in RadioButtonList within a repeater with postback

I have a RadioButtonList inside of Repeater and I want to select just one option at a time. But for each RadioButtonList created dynamically I can select multiple options in each RadioButtonList .

How can I select one option and deactivate the previous selection?

<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>

When a control is rendering in a list bound control, the ID is changed to be unique so JavaScript can work with it. There is a great forum post here about this, and it includes a work-around.

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

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