簡體   English   中英

如何在具有回發的轉發器中的RadioButtonList中僅選擇一個選項

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

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

當控件在列表綁定控件中呈現時,ID將更改為唯一,因此JavaScript可以使用它。 這里有一個很棒的論壇帖子,它包括一個解決方法。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM