title: System.IndexOutOfRangeException: There is no row at position 5?
body: <p>System.IndexOutOfRangeException: There is no row at position 5.</p>
  
  <p>I have the folowing codeblock in my application. This is to enable me to remove rows from a gridview without deleting the same rows completley from the database!</p>
  
  <p>The problem is I am able to remove values but not all of the values when i select in a particular order or more than 3!</p>
  
  <p>This is the error I'm met with!</p>
  
  <p>System.IndexOutOfRangeException: There is no row at position 5.</p>
  
  <p>The comented catch exeption solves the problem slightly.</p>
  
  <pre><code>Dim strQuery As String = "SELECT UserId, staffNo, forename, surname FROM userProfilesTbl WHERE st_id=@st_id AND wa_id=@wa_id ORDER BY surname ASC "
          Dim cmd As New SqlCommand(strQuery)
          cmd.Parameters.AddWithValue("@st_id", myLblSt.Value().ToString)
          cmd.Parameters.AddWithValue("@wa_id", myLblWa.Value().ToString)
  
          Dim dt As DataTable = GetDataConn(cmd)
          'Try
          For Each dr In GridView1.Rows
  
              Dim chkBox As CheckBox = dr.FindControl("RowLevelCheckBox")
  
              If chkBox.Checked = True Then
  
                  dt.Rows.RemoveAt(dr.RowIndex)
                  dt.AcceptChanges()
  
              End If
          Next
          'Catch ex As Exception
  
          'End Try
          GridView1.DataSource = dt
          GridView1.DataBind()
  </code></pre>