Recently, when I was working on a project, I had to display multiple radiobutton In the repeater and implement the Single-choice function. As a result, groupname is added naturally, but this is not the case, when radiobutton in repeater is displayed to the page, the name will automatically add the repeater ID, sequence ct100, and radiobutton ID, which directly leads to the failure of groupname. I have searched for many methods on the Internet, but they are not applicable, such as using <input type = radio> and radiobuttonlist. However, since radiobutton is used, I am too reluctant to change it, the following is my code implementation:
Page
1 <table> 2 <tr> 3 <asp:Repeater runat="server" ID="repbgs"> 4 <ItemTemplate> 5 <td> 6 <asp:RadioButton runat="server" ID="rdo1" Text=‘<%# Eval("name") %>‘ /> 7 </td> 8 </ItemTemplate> 9 </asp:Repeater>10 </tr>11 </table>
The backend will not be displayed in a binding process, and jquery
1 $(‘:input:radio‘).click(function () {2 if ($(this).is(‘:checked‘)) {3 $(this).is(‘:checked‘);4 $(this).parents().siblings().children().removeAttr("checked");5 }6 });
The above is my simple implementation