Please refer this code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$("[id*=lnkSelect]").live("click", function () {
$("[id*=txtId]").val($(".Id", $(this).closest("tr")).html());
$("[id*=txtName]").val($(".Name", $(this).closest("tr")).html());
$("[id*=txtCountry]").val($(".Country", $(this).closest("tr")).html());
return false;
});
</script>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
table
{
border: 1px solid #ccc;
}
table th
{
background-color: #F7F7F7;
color: #333;
font-weight: bold;
}
table th, table td
{
padding: 5px;
border-color: #ccc;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" ItemStyle-CssClass="Id" HeaderText="Id" ItemStyle-Width="30" />
<asp:BoundField DataField="Name" ItemStyle-CssClass="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Country" ItemStyle-CssClass="Country" HeaderText="Country"
ItemStyle-Width="150" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton Text="Select" ID="lnkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
Id
</td>
<td>
<asp:TextBox ID="txtId" runat="server" />
</td>
</tr>
<tr>
<td>
Name
</td>
<td>
<asp:TextBox ID="txtName" runat="server" />
</td>
</tr>
<tr>
<td>
Country
</td>
<td>
<asp:TextBox ID="txtCountry" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</html>
Namespaces
using System.Data;
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", "USA");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title>Untitled Page </title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$("[id*=lnkSelect]").live("click", function () {
$("[id*=txtId]").val($.trim($(".Id", $(this).closest("tr")).html()));
$("[id*=txtName]").val($.trim($(".Name", $(this).closest("tr")).html()));
$("[id*=txtCountry]").val($.trim($(".Country", $(this).closest("tr")).html()));
return false;
});
</script>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
table
{
border: 1px solid #ccc;
}
table th
{
background-color: #F7F7F7;
color: #333;
font-weight: bold;
}
table th, table td
{
padding: 5px;
border-color: #ccc;
}
</style>
</head>
<body>
<div>
<table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse: collapse;">
<tr style="color: White; background-color: #3AC0F2;">
<th scope="col">
Id
</th>
<th scope="col">
Name
</th>
<th scope="col">
Country
</th>
<th scope="col">
</th>
</tr>
<tr>
<td class="Id" style="width: 30px;">
1
</td>
<td class="Name" style="width: 150px;">
John Hammond
</td>
<td class="Country" style="width: 150px;">
USA
</td>
<td>
<a id="GridView1_lnkSelect_0" href="javascript:__doPostBack('GridView1$ctl02$lnkSelect','')">
Select</a>
</td>
</tr>
<tr>
<td class="Id" style="width: 30px;">
2
</td>
<td class="Name" style="width: 150px;">
Mudassar Khan
</td>
<td class="Country" style="width: 150px;">
India
</td>
<td>
<a id="GridView1_lnkSelect_1" href="javascript:__doPostBack('GridView1$ctl03$lnkSelect','')">
Select</a>
</td>
</tr>
<tr>
<td class="Id" style="width: 30px;">
3
</td>
<td class="Name" style="width: 150px;">
Suzanne Mathews
</td>
<td class="Country" style="width: 150px;">
France
</td>
<td>
<a id="GridView1_lnkSelect_2" href="javascript:__doPostBack('GridView1$ctl04$lnkSelect','')">
Select</a>
</td>
</tr>
<tr>
<td class="Id" style="width: 30px;">
4
</td>
<td class="Name" style="width: 150px;">
Robert Schidner
</td>
<td class="Country" style="width: 150px;">
Russia
</td>
<td>
<a id="GridView1_lnkSelect_3" href="javascript:__doPostBack('GridView1$ctl05$lnkSelect','')">
Select</a>
</td>
</tr>
</table>
</div>
<br />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
Id
</td>
<td>
<input name="txtId" type="text" id="txtId" />
</td>
</tr>
<tr>
<td>
Name
</td>
<td>
<input name="txtName" type="text" id="txtName" />
</td>
</tr>
<tr>
<td>
Country
</td>
<td>
<input name="txtCountry" type="text" id="txtCountry" />
</td>
</tr>
</table>
</body>
</html>
Demo