gridview control not updating

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

    You should be using the e.NewValues property.

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now