We help IT Professionals succeed at work.
Get Started

gridview control not updating

dhenderson12
dhenderson12 asked
on
324 Views
Last Modified: 2012-08-13
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);
    }

}
Comment
Watch Question
Developer User Interface
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE