日期:2014-05-17 浏览次数:20465 次
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
string bg=e.Row.BackColor.ToString();
e.Row.Attributes.Add("onmouseover", "this.bgColor='#CED5EC'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.bgColor='" + bg + "'");
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Attributes["onmouseover"] = "_color=this.bgColor;this.bgColor='#cccccc'";
e.Row.Attributes["onmouseout"] = "this.bgColor=_color";
}