zoukankan      html  css  js  c++  java
  • 五、初学.NET—Gridview自动编号和鼠标停留行加背景

    前端:在GridView中添加一普通绑定列

    <asp:BoundField  HeaderText="序号" ItemStyle-Width="60px">

    <ItemStyle Width="60px"></ItemStyle>

            </asp:BoundField>

    后台:通过RowDataBound事件处理代码后台绑定,鼠标停留一行加背景

    protected void gv_ReviewOption_RowDataBound(object sender, GridViewRowEventArgs e)

        {

            if (e.Row.RowType == DataControlRowType.DataRow)

            {  int id = e.Row.RowIndex + 1;

               e.Row.Cells[1].Text = id.ToString();

               e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='lightblue'");//鼠标移上去时

               e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");//鼠标移开时

            }

        }

  • 相关阅读:
    maven常用插件
    Java反编译工具:Java Decompiler
    好看的电影
    我说
    Fisher准则一维聚类
    Java获取函数参数名称
    推荐几个字体生成网站
    Python中的两种路径
    轻量级数据库简介
    Solr Wiki文档
  • 原文地址:https://www.cnblogs.com/liuyuanhao/p/3012950.html
Copyright © 2011-2022 走看看