Raoul_BennetH

Hi all.

I was unable to populate a datagridview with some checkboxcolumn from a database.

In the database, i've already manage my boolean values at first like 'int', then like enum, then like small int.

I've already set the checkboxcolumn trueValue and falseValue to 1 and 0, but when i try to bind i got this error:

The following exception occurred in the DataGridView:

System.FormatException: is not a valid value for Boolean. ---> String was not recognized as a valid Boolean.

Any suggest


RaouL.


Re: Windows Forms Data Controls and Databinding [c#]datagridview checkboxcolumn and boolean value

Luc Morin

Hi,

I'm just guessing, but since there doesn't seem to be a native boolean type in your database, I'm assuming it's Oracle.

What we do to pass boolean values to data binding is define the field as VARCHAR2 with a size of 1. Then, in the DataSet/DataTable, we define the column as System.Decimal.

It might not be the best solution, but it allows us to bind checkboxes to this field.

One word of caution : if you need to re-configure the DataTable, make sure to return the column to System.String before, or else the dataset designer will add a new column as it will not recognize the modified column as being part of the database table. Return it to System.Decimal after configuration (PITA!!!).

Hope this helps.

Luc





Re: Windows Forms Data Controls and Databinding [c#]datagridview checkboxcolumn and boolean value

duongcat

You should set TrueValue = True and FalseValue = False.