Hi SUJAYS,
Please refer below sample.
HTML
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Country" HeaderText="Country" />
<asp:CommandField ShowSelectButton="true" />
</Columns>
</asp:GridView>
<div>
<asp:CheckBox ID="chkName" runat="server" /><br />
<asp:CheckBox ID="chkCountry" runat="server" /><br />
</div>
</div>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("Name", typeof(Boolean)),
new DataColumn("Country",typeof(Boolean)) });
dt.Rows.Add(false, false);
dt.Rows.Add(true, true);
dt.Rows.Add(true, false);
dt.Rows.Add(false, true);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
chkName.Checked = Convert.ToBoolean(row.Cells[0].Text);
chkCountry.Checked = Convert.ToBoolean(row.Cells[1].Text);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("Name", GetType(Boolean)), New DataColumn("Country", GetType(Boolean))})
dt.Rows.Add(False, False)
dt.Rows.Add(True, True)
dt.Rows.Add(True, False)
dt.Rows.Add(False, True)
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
End If
End Sub
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim row As GridViewRow = GridView1.SelectedRow
chkName.Checked = Convert.ToBoolean(row.Cells(0).Text)
chkCountry.Checked = Convert.ToBoolean(row.Cells(1).Text)
End Sub
Screenshot