在gridview中实现鼠标移动,颜色变动。

来源:互联网 发布:音乐打击垫软件 编辑:程序博客网 时间:2024/06/04 23:18

 if (e.Row.RowType == DataControlRowType.DataRow)
        {
         
            //当鼠标停留时更改背景色
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#DDDDDD'");
            ////当鼠标移开时还原背景色
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
        }

把上面句代码加到 gridview中RowCreated事件中,就能实现效果了。