Hi nauna,
Check this example. Now please take its reference and correct your code.
HTML
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
<asp:Label ID="lblteama" runat="server" Text='<%#Eval("Name") %>' CssClass="name"></asp:Label>
<br />
</ItemTemplate>
</asp:ListView>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$(".name").mouseover(function () {
var text = $(this).html();
$('.name').each(function () {
if ($(this).html() == text) {
$(this).css("color", "white");
$(this).css("background-color", "red");
}
});
});
$(".name").mouseout(function () {
$(".name").css("background-color", "");
$(".name").css("color", "black");
});
});
</script>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Name");
dt.Rows.Add("Mango");
dt.Rows.Add("Apple");
dt.Rows.Add("Banana");
dt.Rows.Add("Orange");
dt.Rows.Add("Mango");
dt.Rows.Add("Apple");
this.ListView1.DataSource = dt;
this.ListView1.DataBind();
}
}
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 Data.DataTable = New Data.DataTable()
dt.Columns.Add("Name")
dt.Rows.Add("Mango")
dt.Rows.Add("Apple")
dt.Rows.Add("Banana")
dt.Rows.Add("Orange")
dt.Rows.Add("Mango")
dt.Rows.Add("Apple")
Me.ListView1.DataSource = dt
Me.ListView1.DataBind()
End If
End Sub
Screenshot