Hi everyone. I am new to dotnet so I've been trying toread up and I
run into this frustrating situation.
I downloaded the code below from MSDN at
http://msdn2.microsoft.com/en-us/library/ms996485.aspx
Private Sub dataGrid1_CurrentCellChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DataGrid1.CurrentCellChanged
'if click on a discontinued row, then set currentcell to checkbox
Dim discontinuedColumn As Integer = 0
Dim val As Object = Me.DataGrid1( _
Me.DataGrid1.CurrentRowIndex, _
discontinuedColumn)
Dim productDiscontinued As Boolean = CBool(val)
If productDiscontinued Then
Me.DataGrid1.CurrentCell = _
New DataGridCell( _
Me.DataGrid1.CurrentRowIndex, _
discontinuedColumn)
End If
End Sub
The above is an exact copy of teh code in the aove referenced MSDN
page.
The compiler throws an exception saying "Cast from type 'DBNull' to
type 'Boolean' is not valid" when it gets to this line:
Dim productDiscontinued As Boolean = CBool(val)
The datagrid is populated i.e. there are no nulls
I am using vs.net 2003 if it makes any difference.
What could I be doing wrong?
Thanks in advance
Bill