中继器中只有一个单选按钮选择 [英] only one radiobutton selection in repeater

查看:32
本文介绍了中继器中只有一个单选按钮选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想选择一个单选按钮,但我不能这样做.这是我的代码:

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")); 
            });

这篇关于中继器中只有一个单选按钮选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆