views:

1689

answers:

2

I have a WinForms app with a datagridview and a bindingsource. I want the user to confirm changes before I save them to the database.

I don't want to pop up the confirmation dialog unless I know the user has made changes. So I need a way to check if changes have been made. Any suggestions?

+1  A: 

You should be able to use BindingSource.ListChanged to rig a crude test - set a flag when the event is fired (you'll probably have to clear the flag once binding has completed).

But what is the data? For example, LINQ-to-SQL and DataTable both offer ways of querying for changes... (DataTable.GetChanges() and DataContext.GetChangeSet()). Most DAL-based mechanisms will usually have a way to do this too.

Marc Gravell
+1  A: 

if you're (ultimately) binding to a datatable you can check the rowstate for Changed or Added

Steven A. Lowe