I am looking for a method to convert a SQL bit column (0, 1, NULL) queried into a DataGridViewCheckBoxColumn without using a loop. I tried:
which resulted in the error: "An unhandled exception of type 'System.InvalidCastException' occurred in System.Windows.Forms.dll. Additional information: Value provided for CellTemplate must be of type System.Windows.Forms.DataGridViewTextBoxCell or derive from it."
I believe this has to do with the 3 state value of the bit type in the SQL column (0, 1, NULL). I also thought maybe to CAST the SQL value to a text value, but wasn't sure of the syntax. What is the best way to go about this and avoid the loop? Perhaps if the data only had 0,1 then VB.net would automatically convert this to TRUE/FALSE and display the Checkbox in the DataGridView?
VB.NET Code:
Dim cell As DataGridViewCell = New DataGridViewCheckBoxCell() With DataGridView2 With .Columns("FLY") .CellTemplate = cell End With End With
which resulted in the error: "An unhandled exception of type 'System.InvalidCastException' occurred in System.Windows.Forms.dll. Additional information: Value provided for CellTemplate must be of type System.Windows.Forms.DataGridViewTextBoxCell or derive from it."
I believe this has to do with the 3 state value of the bit type in the SQL column (0, 1, NULL). I also thought maybe to CAST the SQL value to a text value, but wasn't sure of the syntax. What is the best way to go about this and avoid the loop? Perhaps if the data only had 0,1 then VB.net would automatically convert this to TRUE/FALSE and display the Checkbox in the DataGridView?