Dear all,
I'm having serious problems with two datagridviews I have - let's say dtgrd1 and dtgrd2.
Both are bound to SQL tables, and the kind of behavior I would like to achieve is to have both of them displaying all the data at the beginning, but then if I select a row in dtgrd1, I would like dtgrd2 to display only a set of data based on a specific cell value of the selection in dtgrd1.

Therefore this is the code I wrote:

Code:
    Private Sub DtGrd1_DataBindingComplete(sender As Object, e As DataGridViewBindingCompleteEventArgs) Handles DtGrd1.DataBindingComplete

        DtGrd1.ClearSelection()
        DtGrd2.ClearSelection()

    End Sub

    Private Sub DtGrd2_DataBindingComplete(sender As Object, e As DataGridViewBindingCompleteEventArgs) Handles DtGrd2.DataBindingComplete

        DtGrd1.ClearSelection()
        DtGrd1.ClearSelection()

    End Sub
And then:

Code:
Private Sub DtGrd1_SelectionChanged(sender As Object, e As EventArgs) Handles DtGrd1.SelectionChanged

        Dim Filter As String
        Filter = DtGrd1.SelectedRows(0).Cells(1).Value.ToString

        Me.CTO_GiocatoriDataSet.Tbl_CTOPartite.DefaultView.RowFilter = "Codice Like '%" & Filter & "%'"

    End Sub
But then when trying to make a selection in the first datagridview, I get an exception like "System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index'" at the line of the definition of the filter.

How could I get rid of this?

Thanks,
A.