这样好像可以,大家看看。
protected void GridView5_RowCreated(object sender, GridViewRowEventArgs e)
{
Change(e);
}
protected void GridView4_RowCreated(object sender, GridViewRowEventArgs e)
{
Change(e);
}
protected void GridView3_RowCreated(object sender, GridViewRowEventArgs e)
{
Change(e);
}
protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e)
{
Change(e);
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
Change(e);
}
protected void Change(GridViewRowEventArgs e)
{
if ((e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == (DataControlRowState.Selected | DataControlRowState.Normal)) && e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#B1CFF8'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#E3EAEB';");
}
if ((e.Row.RowState == DataControlRowState.Alternate || e.Row.RowState == (DataControlRowState.Selected | DataControlRowState.Alternate))
&& e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#B1CFF8'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='White';");
}
}