Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

only one radiobutton selection in repeater

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.

like image 422
AliRıza Adıyahşi Avatar asked Nov 29 '22 02:11

AliRıza Adıyahşi


1 Answers

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

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

There is a fix available here:

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")); 
            });
like image 171
Curtis Avatar answered Dec 25 '22 10:12

Curtis