I have a DateTimePicker control and a TrackBar control. Both bound to db fields. I am using a bindingSource and a BindingNavigator as well. A user clicks a button on the BindingNavigator to add a new record, then fills out some fields on the form and clicks the save button on the BindingNavigator.
I want to default the datetime in the DateTimePicker to the current date and I want to default the TrackBar value to 1 for every new record. Sometimes the user will not want to set the date value in the DateTimePicker or the value for the TrackBar so I want the values defaulted in case they do not set the values manually.
My problem is this. I have tried to do this several ways and all have failed. I have added code to set the values for each control in the BindingNavigatorAddNewItem_Click event but when the BindingNavigatorSaveItem_Click code fires I get the following exception.
NoNullAllowedException
Column 'MyColumn' does not allow nulls
Somewhere between the time I set the default values for the controls and the BindingSource.EndEdit() call the controls are loosing the default values I am assigning.
Anybody have any ideas or a better way to handle this
Thanks..

Setting Default Values for DateTimePicker and TrackBar
vccool
Add this to your BindingNavigatorSaveItem_Click event before this.validate();
DateTimePicker.Value =
DateTime.Now.ToLocalTime().Date;