Hi nauna,
Check this example. Now please take its reference and correct your code.
Instead of LinkBotton use Botton control.
HTML
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function CallButtonClick(button, e) {
if (e.keyCode == 13) {
$(button).closest('tr').find('[id*=btnView]').trigger('click');
}
}
</script>
<asp:ListView ID="lvCustomers" runat="server" GroupPlaceholderID="groupPlaceHolder1"
ItemPlaceholderID="itemPlaceHolder1">
<LayoutTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<th>
Id
</th>
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
</tr>
<asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<%# Eval("Id") %>
</td>
<td>
<%# Eval("Name") %>
</td>
<td>
<%# Eval("Country") %>
</td>
<td>
<asp:TextBox runat="server" ID="txtCity" onkeypress="return CallButtonClick(this,event)" />
<asp:Button Text="View" runat="server" ID="btnView" OnClick="View" />
</td>
</ItemTemplate>
</asp:ListView>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[3] {
new System.Data.DataColumn("Id", typeof(int)),
new System.Data.DataColumn("Name", typeof(string)),
new System.Data.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");
this.lvCustomers.DataSource = dt;
this.lvCustomers.DataBind();
}
}
protected void View(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('TextBox enter event occured')", true);
}
Screenshot