中继器中只有一个单选按钮选择只有一个、单选、按钮、器中

由网友(不努力,拿什么说明天)分享简介:我只想选择一个单选按钮,但我不能这样做.这是我的代码:I want to select only one radio button but I cant do this.Here is my 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.

我该怎么做.谢谢.

推荐答案

这是使用 RadioButtons 的 ASP.NET 中继器的一个众所周知的错误:

This is a well known bug with the ASP.NET Repeater using RadioButtons:

http://support.microsoft.com/default.aspx?scid=kb;zh-cn;Q316495

这里有一个修复:

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")); 
            });
阅读全文

相关推荐

最新文章