zoukankan      html  css  js  c++  java
  • gridview 的添加删除等技巧 全部按名称取值

    情况1:

    使用dataSource绑定的时候使用一个页面变量,GridViewFlow_RowDeleting先执行,紧接着SqlDataSourceFlow_Deleting

    private int rowIndex;
        protected void GridViewFlow_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            rowIndex = e.RowIndex;
        }
        protected void SqlDataSourceFlow_Deleting(object sender, SqlDataSourceCommandEventArgs e)
        {
            e.Command.Parameters["v_spfabh"].Value = GridViewFlow.DataKeys[rowIndex]["spfabh"].ToString();
            e.Command.Parameters["v_qztz"].Value = GridViewFlow.DataKeys[rowIndex]["qztz"].ToString();
            e.Command.Parameters["v_hztz"].Value = GridViewFlow.DataKeys[rowIndex]["hztz"].ToString();
            e.Command.Parameters["v_gwbh"].Value = GridViewFlow.DataKeys[rowIndex]["gwbh"].ToString();
            e.Command.Parameters["v_gzlx"].Value = GridViewFlow.DataKeys[rowIndex]["gzlx"].ToString();
            e.Command.Parameters["v_czr"].Value = sysUser.Name;
        }

    情况2:使用tableAdapter

    protected void GridViewApproval_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                DataSetClass.ApprovalStateDataTable dt = new DataSetClass.ApprovalStateDataTable();
                DataSetClassTableAdapters.ApprovalStateTableAdapter ta = new DataSetClassTableAdapters.ApprovalStateTableAdapter();
                ta.P_DELCONTRACTSTATE(GridViewApproval.DataKeys[e.RowIndex]["HTZTZ"].ToString(), sysUser.Name);
                this.ShowStateList();
            }
            catch (Exception ex)
            {
                WebAction.MessageBox(this, "add", ex.Message, null);
            }
        }

    需要注意的:如果没使用datasource进行页面的绑定的话,删除或其他操作后,需要主动进行DataBind()的操作,以便删除后能够刷新显示为删除后的列表数据。

  • 相关阅读:
    c++智能指针的一些文章
    c++ template(8)模版多态
    空指针赋值分区
    windbg调试命令
    c++ template(5)模板实战
    GetStockObject 理解
    c++ template(6)模板术语
    c++ template(71)模板参数声明
    DirectDraw教程资料
    c++ template(9)trait和Policy
  • 原文地址:https://www.cnblogs.com/keyrratuff/p/1633526.html
Copyright © 2011-2022 走看看