Wednesday, July 29, 2009

How to change gridview row color on mouse over ?

write this code on row command event



foreach (GridViewRow gvr in gv.Rows)
{
//gvr.Attributes.Add("onMouseover", "MouseOnGridViewRow(this)");
//gvr.Attributes.Add("onMouseout", "MouseOffGridViewRow(this)");


if (gvr.RowState == DataControlRowState.Alternate)
{
gvr.Attributes.Add("onmouseover", "this.style.backgroundColor='#f1eee9';");
gvr.Attributes.Add("onmouseout", "this.style.backgroundColor='#F6F5F1';");
}
else
{
gvr.Attributes.Add("onmouseover", "this.style.backgroundColor='#f1eee9';");
gvr.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF';");
}
}

No comments:

Post a Comment