Home > Code > ASP.NET > Gridview row color change on mouse over and mouse out?

Gridview row color change on mouse over and mouse out?

by Thamil   on Jun 26, 2011   Category: ASP.NET   |  Views: 2327    |  Points: 25   |  Gold 


This is the one of way to change the gridview row color on mouse over and mouse out, place the below code in RowCreated event.

Add the Row created event as like below

<asp:GridView ID="grdVw" runat="server" AutoGenerateColumns="False" 
onrowcreated="grdVw_RowCreated">


protected void grdVw_RowCreated(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover", "self.MouseOverOldColor=this.style.backgroundColor;this.style.backgroundColor='#FF906B'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=self.MouseOverOldColor");
}
}





Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts