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;");
                }
            }

  • 相关阅读:
    指针详解(C语言)
    JMeter接口测试示例(六)——上传文件
    JMeter接口测试示例(五)——添加Cookie
    JMeter接口测试示例(四)——添加HTTP信息头
    JMeter接口测试参数化(函数生成器)
    JMeter接口测试——参数化
    Bootstrap简介
    jQuery文档节点处理,克隆,each循环,动画效果,插件
    什么是 jQuery 和jQuery的基本选择器,层级选择器,基本筛选器
    BOM对象,math对象document对象的属性和操作和 事件的基本操作
  • 原文地址:https://www.cnblogs.com/tongzhenhua/p/1839277.html
Copyright © 2011-2022 走看看