What happens on DataRow.EndEdit

A

Allan Bredahl

Hi All

I have a bit of a problem with using a datarow to store data that is show in
a form.


On form load I set the Value/Text properties of my form elements to the
specific Column values of the DataRow which works just fine.


On form close I assign the specific DataRow Column values to the value of
the form elements, to update the datarow to the newest values.


The problem is that even if I make no changes to the form the DataRow is
changed afterwards no matter what.

The ColumnChanging event is not raised on my datatable, but as soon as I
call the EndEdit method on the datarow, the RowChanged event is raised on
the DataTable.


Even if I make no assignments to the Row values on form close, the
RowChanged event is raised anyhow.

Is this a normal behavior of the datatable to always see the row as changed
if EndEdit is called ??


I'm a bit confused.


Tanks in advance


Allan
 
M

Miha Markic

Hi Allan,

Yes, calling EndEdit (after BeginEdit) will set row state as changed and
invoke RowChanged/ing events.
You might consider using CancelEdit or not to use Begin/End/Cancel edit
mechanism though.
 
A

Allan Bredahl

Thanks a lot for the answer...


Isn't that behavior quite odd ?

I consider the DataRow as changed when its content has changed, not when I
stop editing it.


Hmm, that means that I have to do a manual comparison on all my DataRow
columns and only call EndEdit if anything is changed.

That seams a bit stupid to me :)

thanks

Allan
 
M

Miha Markic

Isn't that behavior quite odd ?

I consider the DataRow as changed when its content has changed, not when I
stop editing it.


Hmm, that means that I have to do a manual comparison on all my DataRow
columns and only call EndEdit if anything is changed.

That seams a bit stupid to me :)

Yes, it might be better :)
 

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