|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
BindingSource design adviceI 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 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 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 |
|||||||||||||||||||||||