hi I have a problem in datagrid

Actually I am having a two datagrids and some other controls in a
usercontrol. I have added this user control to a aspx page. On
clicking a link in the first data grid the second datagrid is
displayed
My first datagrid has a checkbox column added using itemtemplate.
In the usercontrol I have a button called update on which I have to
see which checkboxes are checked based on which I have to update it to
the db.

My problem is when all the controls in the usercontrol are loaded I am
able to access in the checkbox column in my first datagrid else it
throws and error

I have used the following code

Private Sub UpdateAccountDetails()

Dim dgItem As DataGridItem
Dim ctl As Object


For Each dgItem In AcctsGrid.Items
ctl = CType(dgItem.Cells(0).Controls(0), CheckBox)

If Not ctl Is Nothing Then
Dim nViewSite = CType(ctl, CheckBox).Checked
If nViewSite = True Then
'comes inside this if its checked
End If
End If
Next dgItem

End Sub

the error is

Specified argument was out of the range of valid values. Parameter
name: index
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Specified
argument was out of the range of valid values. Parameter name: index

Source Error:


Line 747: For Each dgItem In AcctsGrid.Items
Line 748: ctl = CType(dgItem.Cells(0).Controls(0),
CheckBox)

Also I want to maintain the checked values even if my page get
reloaded.please somebody help me out.

shalin