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
    ");

      }
      }

  • 相关阅读:
    资料下载
    sublime安装AngularJS插件
    Zen Coding: 一种快速编写HTML/CSS代码的方法[Emmet]
    手机号码归属地API
    浅谈JavaScript中的作用域
    原生ajax、jsoup
    Java排序:选择排序
    Java排序:冒泡排序
    Oracle系列一、基本术语
    linux jdk tomcat 安装
  • 原文地址:https://www.cnblogs.com/conquer/p/554388.html
Copyright © 2011-2022 走看看