[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to Bind a checkbox to a binding source object

Posted on 2009-02-13
7
Medium Priority
?
1,444 Views
Last Modified: 2012-05-06
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.DataBindings.Clear()
            'chkLevyCharge.DataBindings.Add("Checked", 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
0
Comment
Question by:CraigLazar
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Accepted Solution

by:
Dabas earned 750 total points
ID: 23642410
The code above is in the designer.vb or in your own code?

Dabas
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 750 total points
ID: 23643068
move the code of binding to the checkbox to the bottom and keep other bindings on the top.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 23643662
hi the code is not in the vb designer.

to code cruiser
i have bound text fields as well and i am using the same method
            txtAmount.Text = ""
            txtAmount.DataBindings.Clear()
            txtAmount.DataBindings.Add("Text", bs, "Amount")

my code to bind to the checkbox is at the bottom
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

Expert Comment

by:Dabas
ID: 23643694
Have you tried without the .Clear() line?
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 23646996
to Dabas:
yes i tried that and still same problem
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 23647826
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.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 23695404
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
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 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