zoukankan      html  css  js  c++  java
  • 设置鼠标滑过GridView行时变色

    设置鼠标滑过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';");
       }
    }

  • 相关阅读:
    ORM是什么?及ORM框架是什么?
    Spring与其两大核心
    装箱和拆箱
    ==和equals的比较
    Vue中ESlint配置文件eslintrc.js文件详解
    RESTful API规范
    CORS跨域djangosetting.py 配置
    LDAP
    模拟浏览器发送请求报文
    学HTTP协议所要知道的基础知识(微总结)
  • 原文地址:https://www.cnblogs.com/zhaiajing1985/p/3091907.html
Copyright © 2011-2022 走看看