GridView DataBound - values not set when EdiIndex <> -1
With the VB below behind a GridView when I step through the code in debug, as I select Edit mode, DataBound fires and iReqID becomes the correct value of the DataKey and iModifiedBy becomes the correct value of iUserName.
When I click "Save", the DataBound fires again and iReqID is 0 and iModifiedBy is "" because it's no longer in Edit mode and the values are not set and SendModifiedByToRequisition doesn't get called. Crap, this is like a catch 22.
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound If GridView1.EditIndex <> -1 Then Dim iReqID As Integer = CType(GridView1.DataKeys(GridView1.EditIndex).Value, Integer) 'CInt(GridView1.DataKeys(GridView1.EditIndex).Value) Dim iModifiedBy As String = iUserName Call SendModifiedByToRequisition(iModifiedBy, iReqID) End IfEnd Sub
Hi again, Carl. Yes, I was thinking the same thing. My experience level is not very high so I'm not sure what event to use when.
Carl Tawn
Basically it's like this:
Editing - Fired when the gird enters edit mode
Updating - Fires when switching back to Read mode, but before data is committed
Updated - Fires when switching back to Read mode and after data is committed
Updating fires prior to Updated.
David Megnin
ASKER
It looks like RowUpdated is where I want to put it.