Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you rollback changes made to a bound DataGridView?

I have a DataGridView with its datasource set to a generic list of custom objects. As the user changes values (in this case checks/unchecks a check box) the underlying boolean field in the object changes.

Should I be creating a "copy" of the List for binding, then updating manually if the user commits, (if so how do you create this copy), or is there a simple way to rollback changes made to the datasource.

(I'm using C#)

like image 723
Stuart Helwig Avatar asked Nov 15 '22 16:11

Stuart Helwig


1 Answers

Technically unless you're telling it to, it's not updating your actual datasource, just the list you've bound to the grid. You're still free to dispose of this list and re-query your source to refresh it back to it's previous state.

You might just add a commit option for the users to commit all the changes they've made back to the actual data source.

It would be a lot easier and probably a whole lot less intensive to handle it like that. Then you can simply have a "cancel changes" or some such option that will refresh and rebind the list from it's source again, without performing an update.

Hope this helps!

Cheers!

like image 141
thismat Avatar answered Dec 10 '22 11:12

thismat