Multiple edits to datarow before submitting to database

S

Simon

Hi,

I was wondering if anyone had come across this problem I'm
having...Basically we have a DataRow object that is edited
by the user. The thing is we want to allow the user to be
able to edit it more than once before submitting it to the
db. The problem is when the user makes a change, then
decides to cancel it. CancelEdit takes the DataRow back to
its very first state, and loses all changes in between the
last save and the cancel. What is needed is for the DataRow
to be taken back one step, not right to the beginning.

We have investigated copying the DataRow's ItemArray using
DataTable.NewRow, but that means the new row's state is
"detached" and different to the original datarow. We would
just take a copy of the DataRow object, but it appears that
cloning objects in .Net isn't that well supported and
requires a lot of work to get working.

Has anyone got any suggestions as to how to go about this?
It seems like something that would be commmonly done. I'm
pretty new to .Net, so forgive me if I've missed a
blantantly obvious solution.

Thanks,
Simon
 
M

Miha Markic

Hi Simon,

How do you edit it? By databinding or directly accessing the row?
In the first case you might call BindingManagerBase.CancelCurrentEdit in the
later you might serialize various versions of dataset - then you'll be able
to do undo operations.
 
G

Guest

Hi Miha,

Thanks, BindingMangerBase.CancelCurrentEdit has basically
solved the problem. Not all my controls use databinding
(because of some wierd issues we've had with databinding -
for eg, controls refusing to give up focus on a second
edit), but the ones that don't I have changed so that they
only update the DataRow on an explicit save, rather than on
a value changed event.

Thanks for the speedy and helpful reply!
Cheers,
Simon

-----Original Message-----
Hi Simon,

How do you edit it? By databinding or directly accessing the row?
In the first case you might call
BindingManagerBase.CancelCurrentEdit in the
 

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