SuspendBinding/ResumeBinding

  • Thread starter Thread starter Christian Ista
  • Start date Start date
C

Christian Ista

Hello,

I have a form where the controls are linked to a Access database via Dataset
Adapter and DataSet. I can navigate in the dataset.

Now I'd like to use the same form to insert data.

For that, my idea is :
- SuspendBinding
- Clear TextBox
- User fill in the Textbox
- Insert in DataRow and after in Database
- ResumeBinding

But I have a problem, when I do this (see below)

I receive this error message (exception raised):
System.Windows.Forms
DataBinding could not find a row in the list that is suitable for all
bindings.

An idea ?

Thanks,

Christian,

The code, in the event button (ADD) click :
try
{
BindingManagerBase binMng=BindingContext [dsMyMovie, "MOVIE"];
binMng.SuspendBinding();
}
catch(Exception ex)
{
MessageBox.Show(ex.Source);
MessageBox.Show(ex.Message);
}
 
Hi Christian,

Didn't you overcomplicated a bit?

You should invoke BindingManagerBase.AddNew() method.
When you are finished editing you should call
BindingManagerBase.EndCurrentEdit().
There you have a DataRow in DataTable.
 
Back
Top