none
Will not accept Null value RRS feed

  • Question

  • I use the following code to display a table value in a form:

    chkCat1.DataBindings.Add("Checked", FileMasterTable, "blnCategory1")

    chkCat1 is a checkbox control.  My understanding is that "Checked" is the binding property the value is attached to.

    So I run into a problem when the column value "blnCategory1" is Null.

    So my question is how do I handle a Null value?


    gwboolean

    Tuesday, April 2, 2019 4:32 AM

Answers

  • Please note the last argument "nullValue" this will be the state you wish to engage when a null is preset. IE

    chkbox.DataBindings.Add("Checked", BSource, "Column", True, DataSourceUpdateMode.OnValidation, CheckState.Indeterminate)


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    • Marked as answer by gwboolean Wednesday, April 3, 2019 12:36 AM
    Tuesday, April 2, 2019 6:53 PM

All replies

  • Hi,

    turn on data formatting

    chkCat1.DataBindings.Add("Checked", FileMasterTable, "blnCategory1",true)

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 2, 2019 5:41 AM
  • Hello,

    My guess is you added a DataColumn to a DataTable of type Boolean.

    dt.Columns.Add(New DataColumn With
                      {
                      .ColumnName = "Process", .DataType = GetType(Boolean)
                      })

    If that is the case then use DefaultValue.

    dt.Columns.Add(New DataColumn With
      {
          .ColumnName = "Process", .DataType = GetType(Boolean),
          .DefaultValue = False
      })
    Otherwise with a column in ms-access of type yes/no there would be no issues as the default value is false from the database.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, April 2, 2019 9:45 AM
    Moderator
  • Please note the last argument "nullValue" this will be the state you wish to engage when a null is preset. IE

    chkbox.DataBindings.Add("Checked", BSource, "Column", True, DataSourceUpdateMode.OnValidation, CheckState.Indeterminate)


    Live as if you were going to die today, learn as if you were going to live forever -Mahatma Gandhi

    • Marked as answer by gwboolean Wednesday, April 3, 2019 12:36 AM
    Tuesday, April 2, 2019 6:53 PM
  • I thank you for the responses.  Because my old back is giving me a lot of trouble this is my first chance to check back on this.

    Gtripodi, that is exactly what was required.  Could you perhaps point me to some information that might help me understand all that is going on with that?  I kind of get some of it, but not even close to all of it.

    Alex,

    I would be happy to turn on data formatting, but am not clear where to go to do that.  What is that a property of?

    Karen,

    I think you are actually doing the same thing as what Alex suggested? Except that the methodology is setup up such that I think I can see what is going on.


    gwboolean

    Wednesday, April 3, 2019 12:36 AM
  • I thank you for the responses.  Because my old back is giving me a lot of trouble this is my first chance to check back on this.

    Gtripodi, that is exactly what was required.  Could you perhaps point me to some information that might help me understand all that is going on with that?  I kind of get some of it, but not even close to all of it.

    Alex,

    I would be happy to turn on data formatting, but am not clear where to go to do that.  What is that a property of?

    Karen,

    I think you are actually doing the same thing as what Alex suggested? Except that the methodology is setup up such that I think I can see what is going on.


    gwboolean

    Hi,


    * First value: Where to bind to the checkbox
    * Second value: What is the data source?
    * Third value: What attributes should be taken from the data source
    * Fourth value: Whether to enable data formatting
    * Fifth value: When to enable data source binding

     checkbox.DataBindings.Add("Checked", FileMasterTable, "blnCategory1",true,DataSourceUpdateMode.OnPropertyChanged)

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 3, 2019 1:14 AM
  • Thanks.  That really does help.  I have been doing a little reading on what I can find about that and it gets pretty complex, pretty quick.

    I can see again!!!!!  I am healed!!!!  Now if something could just be done for my back.


    gwboolean

    Wednesday, April 3, 2019 1:44 AM