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#)
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With