Solution where GridView_RowUpdating cannot get a new value

  • 2020-06-12 08:50:27
  • OfStack


protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        sqlcon = new SqlConnection(strCon);
        sqlcon.Open();
        string bianhao = Convert.ToString(this.GridView1.DataKeys[e.RowIndex].Value);
        string beizhu = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString();
        string sqlstr = "SQL � a '";
        sqlcom = new SqlCommand(sqlstr, sqlcon);
        sqlcom.ExecuteNonQuery();
        sqlcon.Close();
        GridView1.EditIndex = -1;
        bind();
    }

The value of the fetch column is not updated because the value of the fetch column is added to Page_Load. The fetch column is refreshed after each update, so the return of the fetch column is determined in Page_Load, as follows


 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bind();
        }
    }


Related articles: