zoukankan      html  css  js  c++  java
  • GridView:当鼠标滑过,行的背景颜色发生变化

    //这里我们将对NorthWind数据库的Category表进行操作
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
       //将CategoryID为偶数的行 设为银色(Silver)
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
            //判定当前的行是否为数据行(即类型是否为DataRow)
            int cid = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "CategoryID"));
            //获取当前行的CategoryID列的值
            if (cid % 2 == 00)
                e.Row.BackColor = Color.Silver;
       }

       //设置鼠标滑过,行变色的效果
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
            //当鼠标放上去的时候 先保存当前行的背景颜色 并设置新的背景色
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow'; this.style.fontWeight='bold';");
            //当鼠标离开的时候 将背景颜色恢复成之前的颜色
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor; this.style.fontWeight='';");
       }

       //设置鼠标点击,行变色、鼠标指针变 成手状的效果
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
            e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.cursor='hand';");
       } 
    }

    另外:

    FF,IE区别---手型指针

    手型指针有cursor:hand和cursor:pointer两种写法,其中 cursor:hand在ff中不支持,返回错误!
    只要使用cursor:pointer即可,ff和ie都支持!

  • 相关阅读:
    [Hadoop]
    [Linux]
    [Linux]
    [Hadoop]
    [Hadoop]
    vue-学习笔记-API-全局配置
    vue 风格指南-必须的
    vue 学习笔记-复用-自定义指令
    vue学习笔记-过滤器
    vue 学习笔记-复用-对象混入
  • 原文地址:https://www.cnblogs.com/liufei88866/p/1914493.html
Copyright © 2011-2022 走看看