Give the id to tr
here i have created a grdview with dummy records and on mouse over of Address column i am shwing the address in div tag.
HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('[id*=rowAddress]').mouseover(function () {
var Address = $(this)[0].innerText;
$('[id*=divName]').html(Address);
});
});
</script>
<style type="text/css">
.highlightRow
{
color: Red;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div runat="server" id="divAddress">
</div>
<asp:GridView ID="gvLinks" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="Type" HeaderText="Type" />
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<tr id="rowAddress">
<td>
<asp:Label ID="Label1" Text='<%# Eval("Address") %>' runat="server" />
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
C#:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.PopulateGrid();
}
}
private void PopulateGrid()
{
DataTable dt2 = new DataTable();
dt2.Columns.AddRange(new DataColumn[3]{new DataColumn("ID",typeof(int)),
new DataColumn("Address",typeof(string)),
new DataColumn("Type",typeof(string))
});
dt2.Rows.Add(1, "Abc", "Fixed");
dt2.Rows.Add(2, "http://www.google.com", "External");
dt2.Rows.Add(3, "Xyz", "Fixed");
dt2.Rows.Add(4, "Pqo", "Fixed");
dt2.Rows.Add(5, "http://www.w3schools.com", "External");
dt2.Rows.Add(6, "http://www.aspforums.com", "External");
dt2.Rows.Add(7, "Abc", "Fixed");
dt2.Rows.Add(8, "Abc", "Fixed");
dt2.Rows.Add(9, "http://www.aspsnippets.com", "External");
dt2.Rows.Add(10, "Abc", "Fixed");
dt2.Rows.Add(11, "Afdsgsdbc", "Fixed");
this.gvLinks.DataSource = dt2;
this.gvLinks.DataBind();
}
And if you want to select the value of label then
var name = $("[id*=lblName]").val();
Thank You.