DataSet Bound Checkbox Value


I have bound a checkbox to a dataset using
cbSettings.DataBindings.Add("CheckState", BindingSource1, "Settings", True, DataSourceUpdateMode.OnValidation, False)

Open in new window

However, if the checkbox is unchecked then the dataset value is set to NULL whereas it should be 0 (database column is BIT)

The ThreeState property of the checkbox is False

Thanks, Greg
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

spen_langAuthor Commented:
OK, I used the following code in the end to add a new record:

    Private Sub btnAddNew_Click(sender As System.Object, e As System.EventArgs) Handles btnAddNew.Click

        Dim drvUsers As DataRowView

        drvUsers = Me.BindingSource1.AddNew()
        cbActive.Checked = True
        cbEmployeeAccidentRate.Checked = False
        cbInvoiceAccuracy.Checked = False
        cbCreateEditUsers.Checked = False
        cbSettings.Checked = False
        txtWindowsUsername.Text = "(NEW)"
        txtName.Text = ""

        drvUsers.Row.Item("UserID") = txtWindowsUsername.Text
        drvUsers.Row.Item("Username") = txtName.Text
        drvUsers.Row.Item("InvoiceAccuracy") = cbInvoiceAccuracy.Checked
        drvUsers.Row.Item("EmployeeAccidentRate") = cbEmployeeAccidentRate.Checked
        drvUsers.Row.Item("Settings") = cbSettings.Checked
        drvUsers.Row.Item("Users") = cbCreateEditUsers.Checked
        drvUsers.Row.Item("Active") = cbActive.Checked


    End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.