• GridView Edit 和Delete


    前台:                                   

    <asp:CommandField ButtonType="Image"  HeaderText="Edit"   EditImageUrl="~/client_support/images/edit.GIF"  UpdateImageUrl ="~/client_support/images/save.gif" CancelImageUrl="~/client_support/images/cancel.gif"  ShowEditButton ="True"   >
                                        </asp:CommandField>
                                        <asp:TemplateField HeaderText="Delete">
                                            <ItemTemplate>
                                                  <asp:ImageButton ID = "ibnDelete" runat="server"   ImageUrl ="~/client_support/images/del.gif"  CommandName="Delete"
                                                    OnClientClick ="return confirm('Are you sure to delete?');"/>
                                            </ItemTemplate>
                                        </asp:TemplateField>

    后台:

        protected void gdvTax_RowEditing(object sender, GridViewEditEventArgs e)
        {
            try
            {
                this.gdvTax.EditIndex = e.NewEditIndex;
                BindGridView();
            }
            catch (Exception ex)
            {
                AlertExceptionMessage(ex, MethodBase.GetCurrentMethod());
            }

        }

    protected void gdvTax_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {   
                //Update

                AlertMessage("Update success!");
                this.gdvTax.EditIndex = -1;
                BindGridView();
            }
            catch (Exception ex)
            {
                AlertExceptionMessage(ex, MethodBase.GetCurrentMethod());
            }
        }

        protected void gdvTax_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            try
            {
                this.gdvTax.EditIndex = -1;
                BindGridView();
            }
            catch (Exception ex)
            {
                AlertExceptionMessage(ex, MethodBase.GetCurrentMethod());
            }
        }

        protected void gdvTax_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                     //Delete           
                    AlertMessage("Delete success!");
                    BindGridView();
                
            }
            catch (Exception ex)
            {
                AlertExceptionMessage(ex, MethodBase.GetCurrentMethod());
            }
        }

  • 相关阅读:
    一个奇怪的SystemClock_Config问题解决方法
    Keil5下载STM32库
    Entry point (0x08000000) points to a Thumb instruction but is not a valid Thumb code pointer.
    Error: failed to execute 'C:KeilARMARMCC'的解决办法
    C#委托的介绍(delegate、Action、Func、predicate)
    CopyFromScreen在屏幕缩放情况下需要做处理
    C# CEF 封装UserControl
    一个单js文件也可以运行vue
    vue自学入门-3(vue第一个例子)
    vue自学入门-1(Windows下搭建vue环境)
  • 原文地址:https://www.cnblogs.com/andycai/p/1750717.html
Copyright © 2020-2023  润新知