在GridView中移行变色

      在GridView的事件中增加RowDataBound,在这个事件中首先判断当前行是不是数据行,然后进行变色处理,代码如下所示:

if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //鼠标经过时,行背景色变
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#CC0066'");
            //鼠标移出时,行背景色变
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
        }


 

原文地址:https://www.cnblogs.com/daiweixm/p/1526023.html