I have a problem with bound controls and a bindingsource. I'm using vb 2008 and .net 2.0.
I have a few text boxes bound to columns in the binding source.
The backend is a Access database.
I'm using a bindingnavigator to add a new record.
The additem event works fine.
If the user clicks an icon to cancel edit, the code executes
bindingsource.canceledit. This seems to work fine. The row count
on the navigator returns to the correct number before the addnew event occurred. However, the bindingsource seems to have an empty record in it.
As the bindingsource navigates, it eventually gets to the empty record depending on where it's position was when the addnew event fired.
The error received is an invalidcastexception. This error occurs because the record is repostioned
and each time this occurs the code performs calculations using values from the bound controls.
But when it navigates to the empty record, the values in the bound controls are null.
Is there other code besides canceledit to remove the empty record?
I have a few text boxes bound to columns in the binding source.
The backend is a Access database.
I'm using a bindingnavigator to add a new record.
The additem event works fine.
If the user clicks an icon to cancel edit, the code executes
bindingsource.canceledit. This seems to work fine. The row count
on the navigator returns to the correct number before the addnew event occurred. However, the bindingsource seems to have an empty record in it.
As the bindingsource navigates, it eventually gets to the empty record depending on where it's position was when the addnew event fired.
The error received is an invalidcastexception. This error occurs because the record is repostioned
and each time this occurs the code performs calculations using values from the bound controls.
But when it navigates to the empty record, the values in the bound controls are null.
Is there other code besides canceledit to remove the empty record?
Last edited: