Home All Groups Group Topic Archive Search About

BindingSource design advice

Author
22 Feb 2007 5:55 PM
Flomo Togba Kwele
I have a grid bound to a bindingsource. The user clicks on a row and
hits a button on the form to delete the row.

The tableadapter executes its update method but comes back with a
Foreign Key violation. I trap the error and tell the user it's not
allowed, but visually (and in the bindingsource) the row is gone.

What is the proper design approach for this situation? In order for the
update method of the tableadapter to work, I execute
BindingSource.RemoveCurrent just before that. This removes the row from
the bindingsource as well as the grid.

TIA

Author
23 Feb 2007 9:56 AM
WenYuan Wang
Hi Flomo,

According to your description, I understand you want to know what the best
way to cancel delete behavior for databindingsource is. If I have
misunderstood anything here, please don't hesitate to correct me.

As far as I know, we will reject the delete behavior of databindingsource
by the following code  snippet in the catch block.
For example:
try{.......}
catch(Exception)
{(DataSet)(BindingSource.DataSource)).RejectChanges();}

I also appreciate for any better idea for Flomo.
Sincerely.
Wen Yuan
Author
26 Feb 2007 1:12 AM
Earl
Have you tried BindingSource.CancelEdit();

Show quote
"Flomo Togba Kwele" <flomo@community.nospam> wrote in message
news:MPG.204778c12eb3c1f698968d@news.covad.net...
>I have a grid bound to a bindingsource. The user clicks on a row and
> hits a button on the form to delete the row.
>
> The tableadapter executes its update method but comes back with a
> Foreign Key violation. I trap the error and tell the user it's not
> allowed, but visually (and in the bindingsource) the row is gone.
>
> What is the proper design approach for this situation? In order for the
> update method of the tableadapter to work, I execute
> BindingSource.RemoveCurrent just before that. This removes the row from
> the bindingsource as well as the grid.
>
> TIA

AddThis Social Bookmark Button