ASP.NET Web App Support

I have a simple web form that has several fields and a gridview on it. I also have a save and cancel button.

I would like to undo what was done with the form data when the user clicks on undo. It's easy enough with fields, since changes to the gridview happen in real time with respect to the database, I don’t know how to undo functionality.

I thought about saving the changes to the gridview in the viewstate, but I would prefer not because of the extra space requirement.

I also thought of a temporary table in which the changes would be saved, and then rolling them back as needed.

Does anyone have an idea how to undo functionality from a form?

+4
source share
4 answers

Store all the data in the session object and write it to the database when you are ready. If you separate your data layer, you can use an ObjectDataSource object that interacts with session objects.

I am currently using this method in a validation system for an e-commerce site. I store data in user objects that mimic a database schema.

+2
source

The simplest solution is to not push changes to the gridview to the database until the user clicks the Save button.

If you decide to use viewstate or some of them to record changes that you subsequently discard, be sure to take the same re: update collisions precautions that you would have made when you made the initial changes.

+1
source

One way is to save the changes to the table in another table along with the timestamp and identifier for this application instance. If you want to undo changes from a specific time, you simply go back to that date for that identifier.

0
source

Hmmm ... load data objects into a session and bind controls to objects (MyObject)Session["MyObject"] . I believe that you can connect to an ObjectDataSource to use a session ... then you can override Update events so that changes are written to the session.

When the user clicks on save, take the session objects and save them: MyObject obj = (MyObject)Session["MyObject"]; MyObject.Save() MyObject obj = (MyObject)Session["MyObject"]; MyObject.Save()

This will not give you multiple undo levels ... although I think you could save multiple session objects if you really need to.

0
source

Source: https://habr.com/ru/post/1277382/


All Articles