Detect Changes to maually built DataTable

J

Joe

Hi

I am building a datatable manually and putting in a grid

I would like to edit a row then determine that the table has changes and
needs to be saved

The problem I am having is that all the rows in the datatable have a state
of "added" and when I change
a row it still has a RowState of Added

Is there some other way to detect that a row was changed after it was added
to a table???

Thanks
 
V

Vijay

Build the DataTable.. add the Table to a dataset, then Bind the DataSet's
datatable to the grid.., the below statement has to help you then....

<dataTbl>.DataSet.HasChanges(DataRowState.Modified); // modified rows..

<dataTbl>.DataSet.HasChanges(DataRowState.Added); // modified rows..

read MSDN for more help on this property...

Vijay
 
M

Marc Scheuner

I am building a datatable manually and putting in a grid
I would like to edit a row then determine that the table has changes and
needs to be saved
The problem I am having is that all the rows in the datatable have a state
of "added" and when I change a row it still has a RowState of Added

How about calling the .RejectChanges() method on the DataTable once
you've completely populated it? I've never tried your exact scenario,
but if you use the "normal" case where ADO.NET retrieves the rows from
a database, calling .RejectChanges() will discard any changes you may
have made, and I'm pretty sure the RowState will be "unmodified" after
that call.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top