jake072
asked on
Databinding issues
Experts,
I'm really scratching my head. I used to do all my "databinding" programmatically myself, but then I decided, why not use .DataBindings???
Well, I think I know now; they don't bloody work.
I can't databind a checkbox OR numericupdown...
These databindings don't work. All the information is correct, but I'm always getting errors when I .EndEdit saying that these columns do not allow nulls...
I've tried changing "DataSourceUpdateMode.OnPr opertyChan ged" to "DataSourceUpdateMode.OnVa lidation" - no joy.
Is there a solution?
Thanks,
Jake
I'm really scratching my head. I used to do all my "databinding" programmatically myself, but then I decided, why not use .DataBindings???
Well, I think I know now; they don't bloody work.
I can't databind a checkbox OR numericupdown...
These databindings don't work. All the information is correct, but I'm always getting errors when I .EndEdit saying that these columns do not allow nulls...
I've tried changing "DataSourceUpdateMode.OnPr
Is there a solution?
Thanks,
Jake
nudDiscount.DataBindings.Add("Value", MyDataSet.Tables("customers"), "decDiscount", False, DataSourceUpdateMode.OnPropertyChanged, 0)
nudTerms.DataBindings.Add("Value", MyDataSet.Tables("customers"), "numTerms", False, DataSourceUpdateMode.OnPropertyChanged, 0)
chkEDICInsured.DataBindings.Add("Checked", MyDataSet.Tables("customers"), "bitEDCInsured", False, DataSourceUpdateMode.OnPropertyChanged, False)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What datasource are you using and what field property ?
ASKER
I am using MyDataSet.Tables("customer s") as a standard DataSet...
Fields as above.... bitEDCInsured, numTerms, decDiscount
Jake
P.S. Out of office till tomorrow morning - thanks for the help.
Fields as above.... bitEDCInsured, numTerms, decDiscount
Jake
P.S. Out of office till tomorrow morning - thanks for the help.
But do you have the field that gives you problems with allow nulls ?
ASKER
jpaulino,
I'm not sure what you mean. the 3 fields mentioned all do not allow nulls, so I have to set a default value in the dataset, otherwise, the user needs to toggle them manually, or I need to toggle them in code (.Checked = True, then .Checked = False....)
I don't understand why I need to toggle them...
Jake
I'm not sure what you mean. the 3 fields mentioned all do not allow nulls, so I have to set a default value in the dataset, otherwise, the user needs to toggle them manually, or I need to toggle them in code (.Checked = True, then .Checked = False....)
I don't understand why I need to toggle them...
Jake
ASKER
I managed to get it to work... If you setup the DataBindings via the designer, and also toggle the value manually it will work great; otherwise, use default values... But thanks for pointing me in the right direction.
ASKER
Thanks for the reference... It seems that using the attached code WILL send the data back to the controls, however, I don't understand why I keep getting NoNullAllowedException's if the user does not manually go and change the value...
i.e.
If you want 'False' in a checkbox, you have to toggle it to true, then back to false....
If you want 0 in the numericupdown, you have to toggle it to 1, then back to 0...
Why doesn't it pick up the value in there?
I've played with changing the Validation and Property change events to no avail...
Thanks,
Jake
Open in new window