zoukankan      html  css  js  c++  java
  • 行改变色

     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    string key = this.GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
                    e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'};this.style.cursor='hand';");//当鼠标停留时更改背景色
                    e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");//当鼠标移开时还原背景色
                    e.Row.Attributes.Add("onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this);setvalue('" + key + " ')");
                    // e.Row.Attributes.Add("onclick", "alert('"  + key + " ')");
                   
                }
            }

     <script type="text/javascript">
          var prevselitem=null;
           function selectx(row)
          {
                  if(prevselitem!=null)
                 {
                      prevselitem.style.backgroundColor='#ffffff';
                   }
                  row.style.backgroundColor='PeachPuff';
                  prevselitem=row;
                 
          }
          function setvalue(obj)
          {
          document.getElementById("Hidden1").value=obj;
          document.getElementById("dd").innerHTML=obj;
          alert(obj);
           document.all('Button1').click();
     
          }
      </script>

  • 相关阅读:
    @Controller 与 @RestController 的区别
    Java泛型
    Java面试被经常问到的常用算法
    jdk和jre的区别
    Spring获取对象的方式
    xsi:schemaLocation的作用
    SpringBoot学习(一)
    docker-elk装IK自定义分词库
    MySQL存储引擎
    docker环境下elasticsearch安装ik和拼音分词
  • 原文地址:https://www.cnblogs.com/IsNull/p/1718265.html
Copyright © 2011-2022 走看看