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
Private Sub dataGrid1_Curre ntCellChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles DataGrid1.Curre ntCellChanged
'if click on a discontinued row, then set currentcell to checkbox
Dim discontinuedCol umn As Integer = 0
Dim val As Object = Me.DataGrid1( _
Me.DataGrid1.Cu rrentRowIndex, _
discontinuedCol umn)
Dim productDisconti nued As Boolean = CBool(val)
If productDisconti nued Then
Me.DataGrid1.Cu rrentCell = _
New DataGridCell( _
Me.DataGrid1.Cu rrentRowIndex, _
discontinuedCol umn)
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 productDisconti nued 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
run into this frustrating situation.
I downloaded the code below from MSDN at
Private Sub dataGrid1_Curre ntCellChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles DataGrid1.Curre ntCellChanged
'if click on a discontinued row, then set currentcell to checkbox
Dim discontinuedCol umn As Integer = 0
Dim val As Object = Me.DataGrid1( _
Me.DataGrid1.Cu rrentRowIndex, _
discontinuedCol umn)
Dim productDisconti nued As Boolean = CBool(val)
If productDisconti nued Then
Me.DataGrid1.Cu rrentCell = _
New DataGridCell( _
Me.DataGrid1.Cu rrentRowIndex, _
discontinuedCol umn)
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 productDisconti nued 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