Cancelling addition of new row

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
 
B

BD

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top