Here is my simple idea for changing row color of GridView on MouseOver event.
First, we have to create a GridView control, click here for the guide how to create GridView control and bind data to it.
Then, add the following code to your code behind
void grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Alternate)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#FEEEE1';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF';");
}
else
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#FEEEE1';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF';");
}
}
}
This is the result, you can see the second row in pink as the following figure:
Friday, January 13, 2012
Change color of GridView Rows on MouseOver event
2:32 AM
Unknown
No comments
0 comments:
Post a Comment