Help with DataTable RowFilter?

  • Thread starter Thread starter Brett Romero
  • Start date Start date
B

Brett Romero

I have a DataTable named _filteredCriteriaTable. In the RowCollection
ItemArray are these values

_filteredCriteriaTable.rowCollection.list._items[0].ItemArray

- ItemArray {Length=4} System.Object[]
[0] "83446" string
[1] "1" string
[2] "1" string
[3] "3" string

The above match one row with four columns from the set I filled this
datatable with. Does this mean the datatable has only one row?

I then want to get only rows that match the following criteria:

_filteredCriteriaTable.DefaultView.RowFilter = "EventName = " +
this.SystemStatus + " AND SampleStatusName = " + this.SampleStatus + "
AND CycleStatusName = " + this.TrackStage;

The above parameters have these values:
this.SystemStatus = 1
this.SampleStatus = 0
this.TrackStage = 1

When I check _filteredCriteriaTable, it still has the same row as
above, which does not match. What are some of the things I could be
doing wrong here?

I then apply this to a datagrid but it remains empty:

this.Participant.DataSource = mymethod.Filter();

which contains the above code and returns a DataTable.

Thanks,
Brett
 
hi what you have to do is to create a view from the table and bind the view

DataView view =_filteredCriteriaTable.DefaultView;
view.RowFilter ="EventName = " +
this.SystemStatus + " AND SampleStatusName = " + this.SampleStatus + "
AND CycleStatusName = " + this.TrackStage;

this.Participant.DataSource=view
 
I tried your code. There are 278 rows in the original table. After
running the filter, there are still 278 results in the dataview. I
looked at the table object inside view and several rows. Their values
are for the four columns:
[row 1]
1234
1
1
3

[row 2]
1235
1
1
3

The criteria filters on the last three columns. It's values are a=1
AND b=1 AND c=1. Since the last column of each actual row has a three,
these shouldn't be in the view.

I also tried:
DataRow[] rows = _filteredCriteriaDataSet.Tables[0].Select(expression);

which doesn't work with the AND operator. Only the OR, which isn't
what I need.

Brett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top