zoukankan      html  css  js  c++  java
  • gridView RowDataBound事件 鼠标经过行颜色变化及根据字段值显示指定内容

     protected void gvBarInfo_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行是否属于datarow类型的行
                {
                    //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色
                    e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#7f9edb',this.style.fontWeight='';");
                    //当鼠标离开的时候 将背景颜色还原的以前的颜色
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");

                    //根据字段值显示指定内容
                    switch (e.Row.Cells[3].Text.ToString())
                    {
                        case "1":
                            e.Row.Cells[3].Text = "道闸";
                            break;
                        case "2":
                            e.Row.Cells[3].Text = "入口屏";
                            break;
                        case "3":
                            e.Row.Cells[3].Text = "摄像头";
                            break;
                        case "4":
                            e.Row.Cells[3].Text = "发布牌";
                            break;
                    }
                    //根据字段值显示指定内容
                    switch (e.Row.Cells[7].Text.ToString())
                    {
                        case "0":
                            e.Row.Cells[7].Text = "正常";
                            break;
                        case "1":
                            e.Row.Cells[7].Text = "异常";
                            break;
                        case "2":
                            e.Row.Cells[7].Text = "未知";
                            break;
                        default:
                            e.Row.Cells[7].Text = "未知";
                            break;
                    }
                }
            }

  • 相关阅读:
    存储过程之基本语法
    SQL存储过程概念剖析
    SQL2005之SA提权总结
    关于存储过程
    Java开发环境之------MyEclipse快捷键和排除错误第一选择ctrl+1(***重点***:ctrl+1,快速修复---有点像vs中的快速using
    MyEclipse Servers视窗出现“Could not create the view: An unexpected exception was thrown”错误解决办法
    艾泰路由器端口映射怎么设置
    常用端口
    jdbc注册驱动 class.forName()
    MyEclipse不能自动编译解决办法总结
  • 原文地址:https://www.cnblogs.com/lichengcai/p/4359658.html
Copyright © 2011-2022 走看看