Why is boolean column always checked?

B

Brett Romero

I convert a collection to DataSet, reference the first table and throw
that into a DataTable. The DataTable is used as a DataSource for a
DataGrid. The DataGrid has an associated GridTableSyle.

I use the RowChanged() event on a DataTable to capture changed column
data. I get their values and update the collection without errors:

Person.addresscollection[0].IsMailing =
Convert.ToBoolean(e.Row["IsMailing"].ToString());

When the grid has finished initially loading, the IsMailing boolean
column is grayed and checked. I click it once to give focus. Then
click again to uncheck. It also ungreys on the second click. Once I
move off this column, it grays and checks itself. The value for the
above collection field is always false. That is the value coming off
the grid or the above conversion.

I'm setting readonly to false for the boolean column when setting up
the gridtablestyle. Any ideas why the boolean is acting this way in
the grid?

Thanks,
Brett
 
Q

qilinw

The checkbox in a datagrid has 3 states, i.e. if the data value is NULL
rather than TRUE of FALSE, the checkbox is cheched and grayed. So to
solve this problem, you should set the boolean data value to FALSE if
it is NULL.
 
B

Brett Romero

I have only one row in the grid. I see the two boolean columns coming
out of the table have true/false values. I supply the grid this way:

dgAddress.DataSource = dtAddress;

It should be fine. How else can I check if the values are null? I
also have the DataGridBoolColumn set to AllowNull = false.

Thanks,
Brett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top