<asp:GridView AutoGenerateColumns="False" AllowSorting="false" Width="100%" ID="List" runat="server" AllowPaging="false" GridLines="None" ShowHeader="False"> <Columns> <asp:TemplateField ItemStyle-HorizontalAlign="Left"> <ItemTemplate> <asp:RadioButton ID="Criteria" Width="1px" runat="server" GroupName="SelectCriteria" onclick="javascript:ValidateMultipleCheck(this,'CPH_List');" /> <asp:HiddenField ID="hdn" runat="server" Value='<%# DataBinder.Eval (Container.DataItem, "Key") %>' />>' </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Value" ItemStyle-HorizontalAlign="Left" /> </Columns> </asp:GridView>
function ValidateMultipleCheck(control, gridName) { var controlId = control.id; var Parent = document.getElementById(gridName); for (i = 0; i < Parent.rows.length; i++) { var tr = Parent.rows[i]; var td = tr.childNodes[0].childNodes[0]; var item = td.firstChild; if (item != null && item.id != controlId && item.type == "radio") { if (item.checked) { item.checked = false; } } } }
To check the grid view Client id use can write
Response.Write(List.ClientID);
on aspx page load , after getting that id, pass it in place of 'CPH_List'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)