• 行改变色


     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>

  • 相关阅读:
    浅析 Java 中的 final 关键字
    谷歌Java编程风格指南
    分布式事务之两阶段提交协议(2PC)and 使用事件和消息队列实现分布式事务
    零和博弈与木桶定律
    Executors类创建四种常见线程池
    软件设计的原则&101个设计模式-2011年04月25日 陈皓
    编程中的命名设计那点事-陈皓
    从面向对象的设计模式看软件设计- 2013年02月01日 陈皓
    SQL语句
    分布式事务
  • 原文地址:https://www.cnblogs.com/IsNull/p/1718265.html
Copyright © 2020-2023  润新知