Solved

Databinding issues

Posted on 2009-03-31
7
290 Views
Last Modified: 2012-05-06
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.OnPropertyChanged" to "DataSourceUpdateMode.OnValidation" - no joy.

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)

Open in new window

0
Comment
Question by:jake072
  • 4
  • 3
7 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24029059
You can use CurrentItemChanged of BindingSource and do the handle you need.
Check this small example
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23750187.html 
0
 
LVL 14

Author Comment

by:jake072
ID: 24029763
jpaulino,

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

nudDiscount.DataBindings.Add("Value", MyDataSet.Tables("customers"), "decDiscount", True)
 
nudTerms.DataBindings.Add("Value", MyDataSet.Tables("customers"), "numTerms", True)
 
chkEDCInsured.DataBindings.Add("Checked", MyDataSet.Tables("customers"), "bitEDCInsured", True)

Open in new window

0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24030013
What datasource are you using and what field property ?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 14

Author Comment

by:jake072
ID: 24030500
I am using MyDataSet.Tables("customers") as a standard DataSet...

Fields as above....  bitEDCInsured, numTerms, decDiscount

Jake

P.S.  Out of office till tomorrow morning - thanks for the help.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24031643
But do you have the field that gives you problems with allow nulls ?
0
 
LVL 14

Author Comment

by:jake072
ID: 24038731
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
0
 
LVL 14

Author Closing Comment

by:jake072
ID: 31564817
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.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Set value of dynamically created checkboxlist 2 42
VB.NET 2008 (3.5 Framework) Remove all items from List 3 32
Convert datetime to time string 10 28
Groupbox Control ? 2 19
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question