gridview control not updating

Posted on 2012-08-13
Medium Priority
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;

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;

      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;

    catch (Exception ex)

Question by:dhenderson12
LVL 20

Accepted Solution

informaniac earned 2000 total points
ID: 38289599
You should be using the e.NewValues property.

Author Comment

ID: 38289612
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.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question