In this article I will explain with an example, how to implement mutually exclusive CheckBoxList (CheckBoxes) inside GridView in ASP.Net using JavaScript and jQuery.
Mutually exclusive CheckBoxList means when one CheckBox is checked, all other CheckBoxes present in the CheckBoxList will be unchecked.
HTML Markup
The following HTML Markup consists of a GridView with two BoundField columns and a TemplateField column containing an ASP.Net CheckBoxList control.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound = "OnRowDataBound">
        <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
        <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="100" />
        <asp:TemplateField HeaderText="Gender" ItemStyle-Width="150">
                <asp:CheckBoxList ID = "chkGender" runat="server" RepeatDirection = "Horizontal">
                    <asp:ListItem Text="Male" Value="M" />
                    <asp:ListItem Text="Female" Value="F" />
You will need to import the following namespace.
using System.Data;
Imports System.Data
Binding the ASP.Net GridView control
I have created a dynamic DataTable with some dummy data and it is used to populate the GridView control in the Page Load event.
Note: You can learn more about this dynamic DataTable in my article Create DataTable dynamically and bind to GridView in ASP.Net.
protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[4] { new DataColumn("Id"), new DataColumn("Gender"), new DataColumn("Name"), new DataColumn("Country") });
        dt.Rows.Add(1, "M", "John Hammond", "United States");
        dt.Rows.Add(2, "M", "Mudassar Khan", "India");
        dt.Rows.Add(3, "F", "Suzanne Mathews", "France");
        dt.Rows.Add(4, "M", "Robert Schidner", "Russia");
        GridView1.DataSource = dt;
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        Dim dt As New DataTable()
        dt.Columns.AddRange(New DataColumn(3) {New DataColumn("Id"), New DataColumn("Gender"), New DataColumn("Name"), New DataColumn("Country")})
        dt.Rows.Add(1, "M", "John Hammond", "United States")
        dt.Rows.Add(2, "M", "Mudassar Khan", "India")
        dt.Rows.Add(3, "F", "Suzanne Mathews", "France")
        dt.Rows.Add(4, "M", "Robert Schidner", "Russia")
        GridView1.DataSource = dt
    End If
End Sub
Populating the Selected Value of CheckBoxList in GridView
Inside the OnRowDataBound event handler of GridView, first the value of Gender is determined from the DataItem object of the GridView.
Finally the CheckBoxList is referenced using the FindControl method and its selected value is set.
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
    if (e.Row.RowType == DataControlRowType.DataRow)
        string gender = (e.Row.DataItem as DataRowView)["Gender"].ToString();
        CheckBoxList chkGender = (e.Row.FindControl("chkGender") as CheckBoxList);
        chkGender.Items.FindByValue(gender).Selected = true;
Protected Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.DataRow Then
        Dim gender As String = TryCast(e.Row.DataItem, DataRowView)("Gender").ToString()
        Dim chkGender As CheckBoxList = TryCast(e.Row.FindControl("chkGender"), CheckBoxList)
        chkGender.Items.FindByValue(gender).Selected = True
    End If
End Sub
Implement Mutually Exclusive CheckBoxList (CheckBoxes) inside GridView
Inside the jQuery document ready event handler, a click event handler is assigned to each CheckBox of all the CheckBoxLists present inside the GridView.
When a CheckBox is clicked in a CheckBoxList, all the CheckBoxes except the current are unchecked.
<script type="text/javascript" src=""></script>
<script type="text/javascript">
    $(function () {
        $("[id*=chkGender] input").click(function () {
Implement Mutually Exclusive CheckBoxList (CheckBoxes) inside GridView in ASP.Net