zoukankan      html  css  js  c++  java
  • Gridview行根据鼠标的移动变色

    后台代码:

    后台代码
    1 protected void Page_Load(object sender, EventArgs e)
    2 {
    3 if (!IsPostBack)
    4 {
    5 databind();
    6 }
    7 }
    8 public void databind()
    9 {
    10 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ToString());
    11 SqlCommand cmd = new SqlCommand();
    12 cmd.Connection = con;
    13 cmd.CommandText = "Select top 10 * From Customers";
    14 SqlDataAdapter da = new SqlDataAdapter(cmd);
    15 DataSet ds = new DataSet();
    16 da.Fill(ds);
    17 this.GridView1.DataSource = ds.Tables[0];
    18 this.GridView1.DataKeyNames = new string[] { "CustomerID" };
    19 this.GridView1.DataBind();
    20 }
    21 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    22 {
    23 if (e.Row.RowType == DataControlRowType.DataRow)
    24 {
    25 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#ff9900'");
    26 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
    27
    28 }
    29 if (e.Row.RowType == DataControlRowType.Header)
    30 {
    31 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#ff6600'");
    32 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
    33 }
    34
    35 }
    怀揣着一点点梦想的年轻人
    相信技术和创新的力量
    喜欢快速反应的工作节奏
  • 相关阅读:
    职场“潜”规则:心法和技法
    JVM参数配置
    python-编码
    pyserial库-串口通讯模块
    Arduino-舵机
    Arduino-中断
    Arduino-一些函数
    Arduino-位操作
    Nginx (一)Windows下编译Nginx源码以及安装 nginx for windows方法步骤
    MSYS2环境搭建
  • 原文地址:https://www.cnblogs.com/hfliyi/p/1964808.html
Copyright © 2011-2022 走看看