471,354 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Help with DataTable RowFilter?

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

Jan 3 '06 #1
2 12583
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
--
Ansil
Satyam, Hyderabad

"Brett Romero" wrote:
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

Jan 4 '06 #2
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

Jan 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by werk | last post: by
3 posts views Thread by Eric | last post: by
1 post views Thread by Jason | last post: by
1 post views Thread by Gary | last post: by
7 posts views Thread by Jeff | last post: by
3 posts views Thread by Datatable Dataset Datagrid help | last post: by
5 posts views Thread by manmit.walia | last post: by
3 posts views Thread by kevinwolfe | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.