Hi ramco1917,
Please refer below sample.
Note: For this sample i have used temporary DataTable. For more details refer How to create Temporary Table in ASP.Net using C# and VB.Net.
HTML
<table id="tblCustomers">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Country</th>
<th></th>
</tr>
</thead>
<tbody>
<asp:PlaceHolder ID="PlaceHolderTable" runat="server"></asp:PlaceHolder>
</tbody>
<tfoot>
<tr>
<td><asp:Label ID="lblId" runat="server" /></td>
<td><asp:TextBox ID="txtName" runat="server" /></td>
<td><asp:DropDownList ID="ddlCountries" runat="server">
<asp:ListItem Text="Select" Value="0" />
<asp:ListItem Text="United States" Value="United States" />
<asp:ListItem Text="India" Value="India" />
<asp:ListItem Text="France" Value="France" />
<asp:ListItem Text="Russia" Value="Russia" />
</asp:DropDownList></td>
<td></td>
</tr>
</tfoot>
</table>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('body').on('click', '[id*=btnEdit]', function () {
var tr = $(this).closest('tr');
var id = $(tr).find('td').eq(0).html();
var name = $(tr).find('td').eq(1).html();
var country = $(tr).find('td').eq(2).html();
$('#lblId').html(id);
$('#txtName').val(name);
$('#ddlCountries').val(country);
});
});
</script>
Namespaces
C#
using System.Data;
using System.Text;
VB.Net
Imports System.Data
Imports System.Text
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] {
new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string))
});
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
StringBuilder sb = new StringBuilder();
foreach (DataRow dtRow in dt.Rows)
{
sb.Append("<tr>");
sb.Append("<td>" + dtRow["Id"].ToString() + "</td>");
sb.Append("<td>" + dtRow["Name"].ToString() + "</td>");
sb.Append("<td>" + dtRow["Country"].ToString() + "</td>");
sb.Append("<td><a href='#' id='btnEdit' style='cursor: pointer;'>Edit</a></td>");
sb.Append("</tr>");
}
PlaceHolderTable.Controls.Add(new Literal { Text = sb.ToString() });
}
}
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(2) {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String)), New DataColumn("Country", GetType(String))})
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
Dim sb As StringBuilder = New StringBuilder()
For Each dtRow As DataRow In dt.Rows
sb.Append("<tr>")
sb.Append("<td>" & dtRow("Id").ToString() & "</td>")
sb.Append("<td>" & dtRow("Name").ToString() & "</td>")
sb.Append("<td>" & dtRow("Country").ToString() & "</td>")
sb.Append("<td><a href='#' id='btnEdit' style='cursor: pointer;'>Edit</a></td>")
sb.Append("</tr>")
Next
PlaceHolderTable.Controls.Add(New Literal With {
.Text = sb.ToString()
})
End If
End Sub
Screenshot