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

  • 相关阅读:
    WScript.Shell对象的run和exec(脚本调用其他程序)
    Hard link 和 Symbolic link 软链接 硬链接
    SGI STL 红黑树(RedBlack Tree)源代码分析
    宏likely和unlikely
    PCLint输出格式选项
    32位与64位原子操作的问题
    王石与成功的定义
    关于FckEditor基于Asp.net MVC中出现未结束的字符窜常量——解决方案
    崩溃中!Nhibernate的数据分页.
    创建Silverlight技术联盟QQ群 希望大家踊跃加入
  • 原文地址:https://www.cnblogs.com/tongzhenhua/p/1839277.html
Copyright © 2011-2022 走看看