asp.netrepeater

Radio button grouping not working in repeater control


This is what i am trying in aspx page group name is not same in html code how can i manage it pls suggest i am trying with the radio button in side a repeater control

 <asp:Repeater ID="rptGoogleCalenderList" runat="server">
                                <ItemTemplate>
                                    <tr>
                                        <td style="width: 10px;">
                                            <asp:RadioButton ID="radiocalenderList" CssClass="grpGoogleCalenderList"  value="grpGoogleCalenderList" GroupName="GoogleCalenderList" runat="server" />
                                            <%--<input id="" type="radio" name="" />--%>
                                        </td>
                                        <td colspan="3">
                                            <asp:HiddenField ID="hfCalenderId" runat="server" Value='<%#Eval("CalenderId") %>' />
                                            <%#Eval("CalenderName") %></td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>

this is what HTML generated for the above code

                                    <tbody><tr>
                                        <td style="width: 10px;">
                                            <span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_0" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl00$GoogleCalenderList" value="grpGoogleCalenderList"></span>

                                        </td>
                                        <td colspan="3">
                                            <input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl00$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_0" value="omiai468mpv3ghgojvsgqnsiak@group.calendar.google.com">
                                            my ct calender</td>
                                    </tr>

                                    <tr>
                                        <td style="width: 10px;">
                                            <span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_1" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl01$GoogleCalenderList" value="grpGoogleCalenderList"></span>

                                        </td>
                                        <td colspan="3">
                                            <input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl01$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_1" value="">
                                            </td>
                                    </tr>

                                    <tr>
                                        <td style="width: 10px;">
                                            <span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_2" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl02$GoogleCalenderList" value="grpGoogleCalenderList"></span>

                                        </td>
                                        <td colspan="3">
                                            <input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl02$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_2" value="#contacts@group.v.calendar.google.com">
                                            Birthdays</td>
                                    </tr>

                                    <tr>
                                        <td style="width: 10px;">
                                            <span class="grpGoogleCalenderList"><input id="Content_rptGoogleCalenderList_radiocalenderList_3" type="radio" name="ctl00$Content$rptGoogleCalenderList$ctl03$GoogleCalenderList" value="grpGoogleCalenderList"></span>

                                        </td>
                                        <td colspan="3">
                                            <input type="hidden" name="ctl00$Content$rptGoogleCalenderList$ctl03$hfCalenderId" id="Content_rptGoogleCalenderList_hfCalenderId_3" value="en.indian#holiday@group.v.calendar.google.com">
                                            Holidays in India</td>
                                    </tr>

                        </tbody></table>

Solution

  • Use HTML radio button instead of ASP Radio button:-

    <input type="radio" name="GoogleCalenderList" />
    

    Unfortunately, asp radio button don't work inside repeater, so you need to do a work around either at client side or by using HTML control.