Hi SUJAYS,
Take reference to the below code and use in your thre-tier architecture code.
And refer below link for insert :
HTML
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="gvCustomers_SelectedIndexChanged">
<Columns>
<asp:BoundField HeaderText="Name" DataField="Name" />
<asp:BoundField HeaderText="Country" DataField="Country" />
<asp:CommandField ShowSelectButton="true" />
</Columns>
</asp:GridView>
<asp:RadioButton runat="server" ID="rbName" Text="Name" />
<asp:RadioButton runat="server" ID="rbCountry" Text="Country" />
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(true, false);
dt.Rows.Add(true, true);
dt.Rows.Add(false, false);
this.gvCustomers.DataSource = dt;
this.gvCustomers.DataBind();
}
}
protected void gvCustomers_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = gvCustomers.SelectedRow;
rbName.Checked = Convert.ToBoolean(row.Cells[0].Text);
rbCountry.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(True, False)
dt.Rows.Add(True, True)
dt.Rows.Add(False, False)
Me.gvCustomers.DataSource = dt
Me.gvCustomers.DataBind()
End If
End Sub
Protected Sub gvCustomers_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim row As GridViewRow = gvCustomers.SelectedRow
rbName.Checked = Convert.ToBoolean(row.Cells(0).Text)
rbCountry.Checked = Convert.ToBoolean(row.Cells(1).Text)
End Sub
Screenshot