Whats wrong wiht this code? Invalid cast
VB Code:
Dim chkBox As New CheckBox
Dim oOrder As New COrder
For Each di As DataGridItem In dgOrders.Items
chkBox = CType(di.Cells(4).Controls(0), CheckBox)
If chkBox.Checked Then
oOrder.CloseOrder(di.Cells(0).Text)
End If
Next
This code occurs when I hit a save button and it checks which checkboxes in the grid that was checked and update the db (oorder.closeorder)
but the line
VB Code:
chkBox = CType(di.Cells(4).Controls(0), CheckBox)
doesn't work, I get an invalid cast exception... why? is there any other way to do it?
kind regards
henrik