仅在中继器1单选选择 [英] only one radiobutton selection in repeater
问题描述
我只需要选择一个单选按钮,但我不能做到这一点。
这里是我的code:
I want to select only one radio button but I cant do this. Here is my code:
<asp:Repeater ID="Repeater_secenekler" runat="server" DataSource='<%#Eval("Secenekler")%>'>
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="margin-left: 20px;">
<asp:CheckBox ID="CheckBox" runat="server" Text='<%#Eval("OptionName")%>' Visible='<%# Eval("TypeId").ToString() == "1" %>' />
<asp:RadioButton ID="RadioButton" runat="server" Text='<%#Eval("OptionName")%>' Visible='<%# Eval("TypeId").ToString() == "2" %>'
GroupName="RadioButtonGrup" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
我可以选择具有相同的组名的所有单选按钮,但我不想这样。我想只有一个选择。
I can select all radio button with same groupname but I dont want this. I want only one selection.
我怎样才能做到这一点。
谢谢你。
How can I do this. Thanks.
推荐答案
这是使用单选按钮一个众所周知的缺陷与ASP.NET中继器:
This is a well known bug with the ASP.NET Repeater using RadioButtons:
<一个href=\"http://support.microsoft.com/default.aspx?scid=kb;en-us;Q316495\">http://support.microsoft.com/default.aspx?scid=kb;en-us;Q316495
有一个修复程序可以在这里找到:
There is a fix available here:
<一个href=\"http://www.ifinity.com.au/Blog/EntryId/87/Simple-fix-for-Radio-Button-controls-in-an-ASP-NET-Repeater-using-jQuery\">http://www.ifinity.com.au/Blog/EntryId/87/Simple-fix-for-Radio-Button-controls-in-an-ASP-NET-Repeater-using-jQuery
jQuery("[name$='$optValue']").attr("name",jQuery("[name$='$optValue']").attr("name"));
jQuery("[name$='$optValue]").click(function (){
//set name for all to name of clicked
jQuery("[name$='$optValue]").attr("name", this.attr("name"));
});
这篇关于仅在中继器1单选选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!