protected void GridViewUser_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
}
我在上面的事件里写了更新的方法,可是更新后,gridview的编辑模式不取消,还处在编辑的状态下··
但是数据已经更新了···请问改怎么解决啊?

解决方案 »

  1.   

    编辑模式的command是Edit,不是Update
      

  2.   


    这个事件 我也写了 protected void GridViewUser_RowEditing(object sender, GridViewEditEventArgs e)
    {
    //索引编辑时
    this.GridViewUser.EditIndex = e.NewEditIndex;
    Bind();
    }
    protected void GridViewUser_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
    //编辑结束时
    this.GridViewUser.EditIndex = -1;
    Bind();
    }
      

  3.   

     那在update后加
    this.GridViewUser.EditIndex = -1;
    不就OK了吗?
      

  4.   

    GridViewUser.EditIndex = -1;这样应该可以的啊
      

  5.   

    写的地方不对RowUpdating或者RowUpdated里写  this.GridViewUser.EditIndex = -1;
      

  6.   

    protected void GridViewUser_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
    string username = this.GridViewUser.DataKeys[e.RowIndex].Value.ToString();
    string name = ((TextBox)(this.GridViewUser.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim();
     string policeID = ((TextBox)(this.GridViewUser.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim();
    string department = ((TextBox)(this.GridViewUser.Rows[e.RowIndex].Cells[4].Controls[0])).Text.Trim();
    string role = ((DropDownList)this.GridViewUser.Rows[e.RowIndex].FindControl("DropDownRole")).SelectedValue;
                      //更新参数的方法
     new BILL.OperateUser().UpdateUser(username, name, policeID, department, role);
                      //重新绑定
     this.GridViewUser.DataSource = new BILL.OperateUser().SelectOneUser(this.edtUserID.Text, this.edtName.Text, this.edtPoliceNumber.Text, this.edtDepartment.Text, " ");
     this.GridViewUser.DataBind();
     this .GridViewUser.EditIndex = -1;
     this.GridViewUser.SelectedIndex = -1; } protected void GridViewUser_RowUpdated(object sender, GridViewUpdatedEventArgs e)
    {
    //this.GridViewUser.DataSource = new BILL.OperateUser().SelectOneUser(this.edtUserID.Text, this.edtName.Text, this.edtPoliceNumber.Text, this.edtDepartment.Text, " ");
    //this.GridViewUser.DataBind();
    e.KeepInEditMode = false;
    this.GridViewUser.EditIndex = -1;
    this.GridViewUser.SelectedIndex = -1;
    //Bind();
    }
      

  7.   

               this .GridViewUser.EditIndex = -1;this.GridViewUser.DataBind();
      

  8.   

    你说的是在Updateing 里写  还是Updated里写啊?另外我调试的时候 发现 点击“更新”以后 根本就没走Updated事件···
      

  9.   

    是说Updating里把顺序倒一下看看能工作否.