Link to home
Start Free TrialLog in
Avatar of james henderson
james hendersonFlag for United States of America

asked on

gridview control not updating

I am having trouble updating the database from the gridview edit row.  I am building the list of parameters to send to a stored proc, calling the stored proc, and then re-loading the gridview.  However,  at the point where I am populating the values for the parameters, I am getting the original values, not the new values I have already typed into the text boxes.

here are the two events in play:

protected void gvCallList_RowEditing(object sender, GridViewEditEventArgs e)
{
    gvCallList.EditIndex = e.NewEditIndex;
    BindCallList();            
}


protected void gvCallList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    int idx = gvCallList.EditIndex;
    GridViewRow row = gvCallList.Rows[idx];
    string RowId = gvCallList.DataKeys[idx].Value.ToString();

    string PharmacyName = ((TextBox)row.FindControl("txtPharmacyName")).Text;
    string Address1 = ((TextBox)row.FindControl("txtAddress1")).Text;
    string Address2 = ((TextBox)row.FindControl("txtAddress2")).Text;
    string City = ((TextBox)row.FindControl("txtCity")).Text;
    string State = ((TextBox)row.FindControl("txtState")).Text;
    string Zip = ((TextBox)row.FindControl("txtZip")).Text;
    string PhoneNo = ((TextBox)row.FindControl("txtPhoneNo")).Text;
    string FaxNo = ((TextBox)row.FindControl("txtFaxNo")).Text;


    try
    {
      List<ParameterDefinition> inParams = new List<ParameterDefinition>();

      inParams.Add(new ParameterDefinition("RowId", DbType.Int64, Int64.Parse(RowId.ToString())));
      inParams.Add(new ParameterDefinition("PharmacyName", DbType.String, PharmacyName));
      inParams.Add(new ParameterDefinition("Address1", DbType.String, Address1));
      inParams.Add(new ParameterDefinition("Address2", DbType.String, Address2));
      inParams.Add(new ParameterDefinition("City", DbType.String, City));
      inParams.Add(new ParameterDefinition("State", DbType.String, State));
      inParams.Add(new ParameterDefinition("Zip", DbType.String, Zip));
      inParams.Add(new ParameterDefinition("PhoneNo", DbType.String, PhoneNo));
      inParams.Add(new ParameterDefinition("FaxNo", DbType.String, FaxNo));

      DataAccess.ExecuteProcedure("DataConnection", "CallList_Update", inParams);
      gvCallList.EditIndex = -1;

      Match();
      BindCallList();
    }
    catch (Exception ex)
    {
      System.Diagnostics.Debug.WriteLine(ex.Message);
    }

}
ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of james henderson

ASKER

thanks for the response, but I just found the issue:  it was a post-back issue.  I was loading the database on every page load, not looking for post-back.  I works now just by calling the load on if (! IsPostBack).  you get cheap points for this one.