Hi ramco1917,
Please refer below sample.
HTML
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="CustomerId" DataField="CustomerId" />
<asp:BoundField HeaderText="Name" DataField="Name" />
<asp:BoundField HeaderText="Country" DataField="Country" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnView" Text="View" runat="server" OnClientClick="BindData(this)" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<div class="col-lg-12">
<div class="form-group">
<asp:HiddenField ID="hfID" runat="server" />
<label>Name</label> <span style="color: red">*</span>
<asp:TextBox ID="txtName" runat="server" TextMode="MultiLine" Rows="2" class="summernote"></asp:TextBox>
</div>
</div>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
<script type="text/javascript">
function BindData(e) {
var currentRow = $(e).closest("tr");
var id = currentRow.find("td:eq(0)").text();
var name = currentRow.find("td:eq(1)").text();
document.getElementById('<%=hfID.ClientID%>').value = id;
document.getElementById('<%=txtName.ClientID%>').value = name;
};
$(function () {
$('.summernote').summernote();
});
</script>
Namespaces
C#
using System.Configuration;
using System.Data.SqlClient;
VB.Net
Imports System.Configuration
Imports System.Data.SqlClient
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if(!this.IsPostBack)
{
this.GridViewBind();
}
}
private void GridViewBind()
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using(SqlConnection con = new SqlConnection(conString))
{
using(SqlCommand cmd = new SqlCommand("SELECT CustomerId, Name, Country FROM Customers", con))
{
con.Open();
gvCustomers.DataSource = cmd.ExecuteReader();
gvCustomers.DataBind();
con.Close();
}
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.GridViewBind()
End If
End Sub
Private Sub GridViewBind()
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(conString)
Using cmd As SqlCommand = New SqlCommand("SELECT CustomerId, Name, Country FROM Customers", con)
con.Open()
gvCustomers.DataSource = cmd.ExecuteReader()
gvCustomers.DataBind()
con.Close()
End Using
End Using
End Sub
Screenshot