zoukankan      html  css  js  c++  java
  • 鼠标移动DataGrid控件某行改变该行的背景

    在DataGrid控件的数据项的Attributes属性为数据项添加Javascript脚本即可
     (1)   触发onmouseover事件时,执行如下代码设置当前DataGrid项的背景色
                   thiscolor = this.style.backgroundColor,this.style.backgroundColor='#ddf3ff'

     (2)   当触发onmouseout事件时,执行如下代码还原前面的背景色
                this.style.backgroundColor = thiscolor

    在DataGrid控件的ItemDataBound事件

     private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
      {
         //如果当前项不为空
       if(e.Item.ItemIndex != -1)
       {
        //取得当前索引值加1,因为索引是从0开始,给DataGrid自动编号
        int orderID = e.Item.ItemIndex +1;
        e.Item.Cells[1].Text = orderID.ToString();

       }
       if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
       {
        e.Item.Attributes.Add("onmouseover","thiscolor = this.style.backgroundColor,this.style.backgroundColor='#ddf3ff'
    ");
        e.Item.Attributes.Add("onmouseout"," this.style.backgroundColor = thiscolor
    ");

      }
      }

  • 相关阅读:
    MySQL之存储引擎
    MySQL之触发器
    MySQL之存储过程
    MySQL之自定义函数
    MySQL之视图
    三种方式安装mariadb-10.3.18
    Linux创建智能DNS
    CentOS 7 搭建Cobbler实现自动化安装系统
    搭建PXE实现自动化安装系统
    编译安装dropbear
  • 原文地址:https://www.cnblogs.com/conquer/p/554388.html
Copyright © 2011-2022 走看看