Cancelling addition of new row

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

I have a simple Windows form bound to one SQL Server table using the
BindingSource control. I would like to use the BindingNavigator
control to navigate through records. One text box holds a required
field. When I click the AddNew button on the BindingNavigator, a new
record is added to the DataTable and all fields are cleared on the
form. If I happen to press the AddNew button again and the required
text field remains empty, a System.Data.NoNullAllowedException occurs.

How do I cancel the addition of the new row if the required field is
empty?

Thanks!
Scott Adams
 
Disable the binding navigator and any other controls that may allow
additions or deletions while adding/editing a record.

I usually create two functions. EnableAddEdit and DisableAddEdit. The
only purpose of the functions is to set the gui control states depending
on the action being performed.

While adding/editing a record I only enable the Save and Cancel buttons,
and the data controls(textboxes, combo's, etc). Everything else is
disabled (binding navigator, other buttons, menus,etc.)

HTH
 
Back
Top