【问题标题】:Radgrid changing mode after insert record插入记录后 Radgrid 更改模式
【发布时间】:2014-03-09 06:50:33
【问题描述】:

一旦记录成功插入数据库,我正在尝试将网格模式从插入更改为显示。这是我到目前为止的代码。不幸的是,添加后,网格仍处于插入模式

 protected void gridLoc_InsertCommand(object sender, GridCommandEventArgs e)
 {
    GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
    TextBox txtLocName= insertItem.FindControl("txtLocName") as TextBox;
    locBLL.InsertLoc(txtLocName.Text, false);
    gridLoc.DataBind();

}

【问题讨论】:

    标签: c# radgrid


    【解决方案1】:

    请尝试以下方法:

    // close the insert form
     e.Canceled = true;
     gridLoc.MasterTableView.IsItemInserted = false;
     gridLoc.MasterTableView.Rebind();
    

    但是不要忘记删除该行:gridLoc.DataBind();

    代码的最终版本:

    protected void gridLoc_InsertCommand(object sender, GridCommandEventArgs e)
     {
        GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
        TextBox txtLocName= insertItem.FindControl("txtLocName") as TextBox;
        locBLL.InsertLoc(txtLocName.Text, false);
        // close the insert form
        e.Canceled = true;
        gridLoc.MasterTableView.IsItemInserted = false;
        gridLoc.MasterTableView.Rebind();    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-14
      • 2015-11-26
      • 2015-05-03
      • 2022-01-26
      • 1970-01-01
      相关资源
      最近更新 更多