鼠标经过GridView的行改变行颜色

来源:互联网 发布:淘宝套餐无线链接转换 编辑:程序博客网 时间:2024/06/11 01:46
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow) //判断是否是DataRow,以防止鼠标经过Header也有效果
        {
            e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#cccccc'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");
        }
    }