CraigLazar
asked on
How to Bind a checkbox to a binding source object
Hi,
I am using VB.net 2008 and i am having trouble binding to a checkbox on my form.
this is my code
'chkLevyCharge.Checked = False
'chkLevyCharge.DataBinding s.Clear()
'chkLevyCharge.DataBinding s.Add("Che cked", bs, "LevyCharge")
it binds to it and when i scroll through the bs object it works, however the problem is when i try and add a new record to the bs (dataset)
bs.addNew() it does not clear the rest of my text boxes which i have bound to the bs, when i comment out the section of code binding to the checkbox then the bs.addnew() method works
thanks
I am using VB.net 2008 and i am having trouble binding to a checkbox on my form.
this is my code
'chkLevyCharge.Checked = False
'chkLevyCharge.DataBinding
'chkLevyCharge.DataBinding
it binds to it and when i scroll through the bs object it works, however the problem is when i try and add a new record to the bs (dataset)
bs.addNew() it does not clear the rest of my text boxes which i have bound to the bs, when i comment out the section of code binding to the checkbox then the bs.addnew() method works
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you tried without the .Clear() line?
ASKER
to Dabas:
yes i tried that and still same problem
yes i tried that and still same problem
Set a default value for the checkbox column in the dataset. I think the problem is that the field to which the checkbox is bound contains DBNull when a new record is inserted which may be causing problems.
ASKER
Hi,
i still battled to get it working, so i landed up using a hidden text box to store the value then i got it working
thanks for the help anyway
i still battled to get it working, so i landed up using a hidden text box to store the value then i got it working
thanks for the help anyway
ASKER
to code cruiser
i have bound text fields as well and i am using the same method
txtAmount.Text = ""
txtAmount.DataBindings.Cle
txtAmount.DataBindings.Add
my code to bind to the checkbox is at the bottom