zoukankan      html  css  js  c++  java
  • 给DataGrid的删除按钮添加"删除确认"对话框

    private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)

             {

                  foreach(TableCell tc in e.Item.Cells)//枚举该行中的每个单元格

                  {

                       if(tc.Controls.Count>0)//检查每个单元格中的控件数

                       {

                           foreach(Control con in tc.Controls)//得到每个控件

                           {

                                if(con.ToString()=="System.Web.UI.WebControls.DataGridLinkButton")//检查每个控件,看是否是DataGridLinkButton

                                //奇怪的是在System.Web.UI.WebControls中没有这个类,我是通过Response.Write(con.ToString())发现的

                                {

                                     LinkButton lb=(LinkButton)con;

                                     if(lb.CommandName=="Delete")

                                     {

                                         lb.Attributes.Add("onclick", "return confirm('您真的要删除此行吗?')");

                                     }

                                }

                           }

     

                       }

                  }

                 

             }

  • 相关阅读:
    web页面性能优化之接口前置
    python大佬养成计划----flask_bootstrap装饰网页
    撸个查询物流的小程序,欢迎体验
    FullCalendar插件的基本使用
    GeekforGeeks Trie
    使用Django和Python创建Json response
    nginx-gridfs的安装
    Linux kernel config and makefile system
    hadoop日志分析
    安装STS报错(三)
  • 原文地址:https://www.cnblogs.com/dudu/p/1168.html
Copyright © 2011-2022 走看看