I’ve got a user modification page, that displays a list of reports a user has access to using a GridView object.
What I want to do is, if someone makes a bunch of changes to a users page, but then clicks cancel, all changes that are made will be undone.
My main issue here is the GridView, which has add/delete/modify buttons, tied to a separate table.
So if I open my own page, add a new report to the gridview, then hit cancel, I don’t want that report to be saved to my account..
Likewise, if I delete a record, and then hit cancel, the record is not deleted.
What is the best way to do this?
You need to maintain this in the
datatableand put this in aSessionvariable and bind your gridview to your datatable that is in the session. So once you are finished with the changes and want to submit the changes in the DB, you have toplay with Datatable Row State, from which you can find which row is added and which one is Deleted or Modified.Have a look at this article to understand Datatable Row state
system.data.datarow.rowstate