zoukankan      html  css  js  c++  java
  • gridview中如何添加对某行删除时的确认提示框

    1.在RowDateBound事件中添加:
    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
            {          
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
                    {
                        ((LinkButton)e.Row.Cells[1].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除名称为:\"" + e.Row.Cells[3].Text.ToString().Trim() + "\" 的票据类型吗?')");
                    }
                }
            }


    2.转为模板列,在前台直接添加:
    <asp:TemplateField HeaderText="删除" ShowHeader="False">
                            <ItemTemplate>
                                <asp:ImageButton ID="ImageButton10" runat="server"
                                OnClientClick="javascript:return confirm('您是否确认要删除选定的送货单?');"
                                 CommandName="Delete" CausesValidation="False"
                                    ImageUrl="~/images/Gridview_Delete/record_delete_16x16.gif" />
                            </ItemTemplate>
                        </asp:TemplateField>

    对比DataGrid

      protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    LinkButton lb = (LinkButton)e.Item.Cells[4].Controls[0];
                    lb.Attributes.Add("onclick", "javascript:if(!window.confirm('Delete,YES or NO ?')) return false;");
                }
            }

  • 相关阅读:
    数据库事务
    什么场景应该用 MongoDB ?
    ES6 箭头函数 =>
    HTML5 <template>标签元素简介
    ES6新特性:使用新方法定义javascript的Class
    Windows平台下Git(gitblit)服务器搭建
    利用WiFi Pineapple Nano渗透客户端获取SHELL
    出现 “未能创建此平台,因为已存在同名的解决方案平台”提示,是什么原因?
    VS2010 常用快捷键
    C# WINFORM 捕获全局异常
  • 原文地址:https://www.cnblogs.com/tongzhenhua/p/1839277.html
Copyright © 2011-2022 走看看