Following code will explain:
How to Highlight Gridview which uses alternate row color.
protectedvoid OnRowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//On Mouse over highlight gridview
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffff00'");
//On Mouse out restore girdview row color based on alternate row color//Please change this color with your gridview alternate color.
if (e.Row.RowIndex % 2 == 0)
{
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#F7F7DE'");
}
else
{
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}
}
No comments:
Post a Comment