VB Code:
  1. Dim chkBox As New CheckBox
  2.         Dim oOrder As New COrder
  3.         For Each di As DataGridItem In dgOrders.Items
  4.             chkBox = CType(di.Cells(4).Controls(0), CheckBox)
  5.             If chkBox.Checked Then
  6.                 oOrder.CloseOrder(di.Cells(0).Text)
  7.             End If
  8.         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:
  1. 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