In my application it has two datagridviews named datagridview1 and datagridview2 and I have the selectionChanged event in datagridview1 that captures the data that is selected in it so that the content of datagridview2 is also changed based on what the product name of the selected row in datagridview1 is. I don't know why I have an index that is out of range because I have checked that I have at least 1 row and 2 columns in datagridview1.
I am using DataView RowFilter function.

**Here is my code:**

```
private void datagridview1_SelectionChanged(object sender, EventArgs e)
{
    view_1.RowFilter = "product_name = '" + datagridview1.SelectedRows[0].Cells[1].Value.ToString() +"'";
}

```