By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,728 Members | 753 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,728 IT Pros & Developers. It's quick & easy.

How do I "roll back" a bad new row in a dataset/table?

P: n/a
Hi all,

I've got a datagrid bound to a dataset/table. When the OnRowChanging
event fires, the handler attempts to Insert the new record into the
database. When there's an error with this Insert operation, it gets
trapped (message displayed). The datagrid still displays the bad
record - I'd like to delete the record from the datagrid. All I (think
I) have available to me in the exception handler is the row itself
(Exception ex.Row). When I try ex.row.rejectchanges, I get a runtime
error dialog telling me:

"Cannot call CancelEdit inside an OnRowChanging event. Throw an
exception to cancel this update. Do you want to correct the value?"

How can I get the bad row off of my datagrid?

Thanks for any ideas,

cdj

Feb 23 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Feb 22, 7:15 pm, "sherifffruitfly" <sherifffruit...@gmail.com>
wrote:
Hi all,

I've got a datagrid bound to a dataset/table. When the OnRowChanging
event fires, the handler attempts to Insert the new record into the
database. When there's an error with this Insert operation, it gets
trapped (message displayed). The datagrid still displays the bad
record - I'd like to delete the record from the datagrid. All I (think
I) have available to me in the exception handler is the row itself
(Exception ex.Row). When I try ex.row.rejectchanges, I get a runtime
error dialog telling me:

"Cannot call CancelEdit inside an OnRowChanging event. Throw an
exception to cancel this update. Do you want to correct the value?"

How can I get the bad row off of my datagrid?

Thanks for any ideas,

cdj
Do what it says, throw an exception in the OnRowChanging event instead
of calling ex.Row.RejectChanges.
Feb 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.