Thursday, November 25, 2010

allowing only one radio button to be selected from all the radio buttons in Item template of Data List

I recently faced a problem in which I wanted that a user should be able to check only one Radiobutton from the RadioButton that was in the ItemTemplate of a DataList.I tried to use GroupName property of radiobutton but that didnot work because when DataList is rendered unique groupname is generated for each radiobutton which means that all the radiobuttons will have different GroupName and you can select any number of radiobuttons.I searched on the net and the answers were not satisfying.So i decided to find a workaround for this using jquery.For this all you have to do is instead of asp:RadioButton use <input type="radio" id="rd" name="rdGroup" /> , Remember to exclude runat="server" from the input tag,if you don't do so then the groupname will again be unique for each radio button

No comments:

Post a Comment