Html
<asp:TemplateField ItemStyle-Width="22px"> <ItemTemplate> <asp:RadioButton ID="radButtonControl" GroupName="group1" runat="server" /> </ItemTemplate> </asp:TemplateField>
CS
protected void gvWorkPlanList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { RadioButton rb = (RadioButton)e.Row.FindControl("radButtonControl"); if (rb != null) rb.Attributes.Add("onclick", "onRadiobuttonClick(‘" + this.gvWorkPlanList.ClientID + "‘,‘" + rb.ClientID + "‘)"); } }
JS
/** // * The passed gridviewclientid and the selected radiobutton clientid **/function onradiobuttonclick (gvcontrolid, selectedcontrolid) {var inputs = document. getelementbyid (gvcontrolid ). getelementsbytagname ("input"); For (VAR I = 0; I <inputs. length; I ++) {If (inputs [I]. type = "radio") {If (inputs [I]. id = selectedcontrolid) Inputs [I]. checked = true; else inputs [I]. checked = false ;}}}
Radiobutton radio effect in gridview