James Morrish
James Morrish

Reputation: 475

How to stop datatable RowFilter dynamically updating

I have a datatable that i am filtering with this rowfilter:

        requestsTableAdapter.Fill(iTSTDataSet.Requests);

        DataTable adt = iTSTDataSet.Requests;
        var adv = new DataView(adt);
        adv.RowFilter = "Closed = " + false;
        dataGridView1.DataSource = adv;

It works perfectly and filters the datatable and only shows rows where closed = false.

The issue is, when i click on the checkbox and set another row to closed, that row will disapear from the datagridview automaticaly.

enter image description here

I dont want it to, i want it to update the view when i click a button.

Upvotes: 1

Views: 285

Answers (2)

kibblator
kibblator

Reputation: 41

Couldn't you just defer adding the row filter on the dataView until you've clicked the button? That should allow you to check the boxes to show the status but stop the rows disappearing until you want them to.

It would mean that you'd need to make the dataView accessible from wherever the command comes from, but is that too much of an issue?

Edit

You can get the original dataTable minus closed items using a data table select at the start: iTSTDataSet.Requests.Select("Closed = false")

and then apply the row filter on button press

Upvotes: 1

Staren
Staren

Reputation: 25

I think you have there a filter that shows only rows that are not closed (Where closed = false) so you might just want to filter by "Closed" then choose Ascending or Descending order, one of those might be the right solution

Upvotes: 0

Related Questions