[英]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.