• GridView中添加自动编号,以及鼠标经过时行背景色变和删除时提示。


     1     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
     2     {
     3         //如果是绑定数据行 //清清月儿http://blog.csdn.net/21aspnet 
     4         if (e.Row.RowType == DataControlRowType.DataRow)
     5         {
     6             ////鼠标经过时,行背景色变
     7             //e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
     8             ////鼠标移出时,行背景色变
     9             //e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
    10 
    11             ////当有编辑列时,避免出错,要加的RowState判断
    12             //if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
    13             //{
    14             //    ((LinkButton)e.Row.Cells[6].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
    15             //}
    16 
    17         }
    18         if (e.Row.RowIndex != -1)
    19         {
    20             int id = e.Row.RowIndex + 1;
    21             e.Row.Cells[0].Text = id.ToString();
    22         }
    23 
    24     }

  • 相关阅读:
    0.Mysql优化框架
    [C]extern char **environ
    [C]Armstrong Number
    [C]struct, union的结合
    [C]enum类型
    [C]fibonacci series, recursion, time.h
    [C/JAVA]二维数组
    [C] char**, swich-case, refactoring, stdbool.h
    hardly/scarcely ... goes by without ...
    [C]随机数生成
  • 原文地址:https://www.cnblogs.com/feb9903/p/709258.html
Copyright © 2020-2023  润新知