-
Feb 19th, 2020, 05:08 AM
#1
Thread Starter
Frenzied Member
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
-
Feb 19th, 2020, 10:16 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|