If you use a SP to update the main table, you can just put this INSERT INTO as the first action in the SP. I was probably not clear about that before, but I was trying to make all of this happen when a detailsview has been edited, the sub is: Protected Sub Data Table_Item Updating(By Val sender As Object, By Val e As System.
And a good "trick", too, is to add one more field to the history table: When Added To History DATETIME DEFAULT get Date() So now you automatically have a complete audit trail. Ok, that makes more sense - but I am still unclear on how to reference the old values inside this Item Updating event. Item Updating How do I get the key of the record that is about to be updated in this subroutine to pass to the stored procedure?
In addition to that, we’re resetting the Edit Index and Selected Index when the page is changed to avoid cases, for example, where you change pages and are suddenly editing a different item.
Bind Data could be called in Page Index Changing, but to show that it the event is raised, we’ve handled that in Page Index Changed.
The important point is not which of these two events call Bind Data, but one of them must or the Grid View will not be updated. When bound using a Data Source ID, the Grid View internally tracks the current Sort Expression and Sort Direction, and those are available through properties with the same names.
When you manually bind the Grid View, this tracking does not occur, so we must implement some mechanism for tracking those values.
I have two tables - one which displays a row in a Details View on my web form, and the second to store a snapshot of the old record if it gets edited and updated.