My rowfilter works fine on one DataTable but not on the other

36 Views Asked by At

I am using an Access database with multiple tables. Each table is displayed in a separate Datagrid.

Now I wanted to filter each table with their own corresponding TextBox using the following code:

private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
    DataView DV = new DataView(myDataSet.table1);
    DV.RowFilter = string.Format("columnToFilter LIKE '%{0}%'", textBox1.Text);
    table1DataGrid.DataContext = DV;
}

For the second table I use exactly the same code.

private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
{
    DataView DV = new DataView(myDataSet.table2);
    DV.RowFilter = string.Format("columnToFilter LIKE '%{0}%'", textBox2.Text);
    table2DataGrid.DataContext = DV;
}

The filter works fine for table1. As soon as I start typing in textBox1 the displayed DataGrid automatically updates. However when I type something in textBox2 nothing happens.

Can somebody help me figure out why the second filter doesn't work?

0

There are 0 best solutions below