Tuesday, June 21, 2011

Code for How to Highlight Row of Gridview on Mouse Over which doesn't use alternate row color in Asp.net

In .aspx File declare OnRowCreated eventas follow.


Following code will:
Highlight Gridview which is not using alternate row color.
protectedvoid OnRowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//On Mouse Over Highlight Row
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffff00'");

//On Mouse out restore default row color
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}

No comments:

Post a Comment