update and cancel update on a datarow

N

Naim Rizk

I have some textboxes bound to a datatable.

pressing the cancel button cancels the changes
pressing the save button saves the changes

that works fine but
i noticed that if i edit a textbox and i pressed the cancel or save
button while the focus is still on the textbox the text that is in the
current textbox isn't reflected in the datarow, and this it won't be
saved or canceled. however if i moved the focus from the edited textbox
(i clicked another one for ex) then pressed the save or cancel button
the appropriate changes are made.

i used: datatable.acceptchanges/ rejectchanges
so to go around this problem i used
datarow.begineEdit / cancelEdit / endEdit

this solved the problem of the cancel but not the save

in the end i programmatically removed the focus from the text box and it
worked, although that doesn't seem the ideal solution to use.
so i was wondering if there's a known solution for this problem.

regards
 
D

Darren Shaffer

this isn't a problem Naim - until your TextBox fires the Validated event
the edits will not be reflected in your bound datatable. By changing the
focus
away from the textbox, you cause this event to be fired.

-Darren
 

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