Question : GridView update is not grabbing the new data when Updating

I have the attached code works great.  SQL table gets updated.  The only problem is that the sXML contains the original vales, and not the updated grid values.  I know the SQL table update works because I can change the sXML value in debug mode.  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        Dim row = GridView1.Rows(e.RowIndex)
        Dim sXML As String

        sXML = "<Resources OfficeID='" & CType(row.Cells(1).Controls(0), TextBox).Text & "'"
        sXML &= " OfficeName='" & CType(row.Cells(3).Controls(0), TextBox).Text & "'"
        sXML &= " RegionID='" & CType(row.Cells(2).Controls(0), TextBox).Text & "'>"
        sXML &= " UserName='" & row.Cells(3).Controls(0).ToString & "'>"
        sXML &= "</Resources>"

        Dim SQLParamList As New ArrayList
        SQLParamList.Add(New SearchParameter("@xmlString", sXML))
        Utils.DBUtilities.spExecute("spInsertOffices", SQLParamList)

        Response.Redirect("/WebForms/OfficeLocations.aspx")
        'Reset the edit index.
        GridView1.EditIndex = -1

        'Bind data to the GridView control.
        BindGrid()
    End Sub
End Class

Answer : GridView update is not grabbing the new data when Updating

Issue resolved by adding the following:

Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.PageIndexChanged, GridView1.Load
       If GridView1.EditIndex = -1 Then
           BindGrid()
       End If
   End Sub
Random Solutions  
 
programming4us programming4us