Results 1 to 2 of 2

Thread: Save unchecked datagridview column to database

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Save unchecked datagridview column to database

    Hi,

    In the database I have a table where one of the columns (named "Response") is of "bit" datatype. That column is not allow Nulls.

    In my application I have a datagridview (bound to that table)

    The "Response" column in the datagridview is now a checkbox column. I do not want to have it "ThreeState" so i set that to FALSE. It must be checked or not checked. Nothing else.

    So when the datagridview load then all the rows are "unchecked"

    But now.. say there is 5 rows and I check only 1 row (so 4 is unchecked) and try to save it tells me cannot save NULL values. So the problem is that the 4 unchecked rows is NULL...

    If I do check the rows it saves to database as every row as TRUE....

    Why is the unchecked rows not saved as FALSE automatically?

    How can I do this, please?

    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Save unchecked datagridview column to database

    The grid is not the data. It's the UI. The DataTable is the data. The default value for any DataColumn is DBNull.Value unless you change it. If you want that DataColumn to default to False then you have to specify that in the DataColumn.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width