首页 > Web开发 > 详细

Asp.net中GridView 当鼠标停留时更改所在行背景色

时间:2021-05-10 10:34:12      阅读:27      评论:0      收藏:0      [点我收藏+]

1.在GridView数据行正常显示后,点击GridView,找到RowDeleting事件双击:

技术分享图片

 2.双击进入RowDeleting事件后台,写入如下代码即成。

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // 当鼠标停留时更改背景色
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor=‘#8EC26F‘");
            // 当鼠标移开时还原背景色
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            // 设置悬浮鼠标指针形状为"小手"
            e.Row.Attributes["style"] = "Cursor:hand";
        }

3.效果:当鼠标经过行时所在行显示为草绿色(#8EC26F)。

 技术分享图片

 

Asp.net中GridView 当鼠标停留时更改所在行背景色

原文:https://www.cnblogs.com/sgxw/p/14749727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!