By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,724 Members | 863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,724 IT Pros & Developers. It's quick & easy.

filter a column with multiple values

nev
100+
P: 251
i declared 2 datatables:

dim dtt1 as datatable = ds.datatable1
dim dtt2 as datatable = ds.datatable2

dtt1 has firstname, lastname columns
dtt2 has firstname column

when i filter dtt1 by lastname, there will be a lot of firstnames

what can i do to filter dtt2 by all those firstnames?

i can filter a column by 1 value like .rowfilter= "firstname='" & firstname1 & "'"

i want to know how to filter a column with multiple values (taking note that the firstname may have none to a lot of values). if i do this...

.rowfilter="firstname='" & fn1 & "AND firstname='" & fn2 & " AND so on...'"

this will take forever. is there any way i could filter dtt2 with all the firstnames i got after filtering dtt1?
Nov 21 '07 #1
Share this Question
Share on Google+
7 Replies


Shashi Sadasivan
Expert 100+
P: 1,435
Iterate throug each row of the grid
and check if the isRowVisible(RowHandle) is true.
then use that row to fetch the id,s and create the AND statment for the next grid

I am using the context of gridview beacause it has the RowFilter Property, while datatables i think dont have that.
Nov 21 '07 #2

nev
100+
P: 251
nev
Iterate throug each row of the grid
and check if the isRowVisible(RowHandle) is true.
then use that row to fetch the id,s and create the AND statment for the next grid

I am using the context of gridview beacause it has the RowFilter Property, while datatables i think dont have that.
ok, i'll check it out. thank you.
Nov 21 '07 #3

nev
100+
P: 251
nev
i was thinking is there a way i can relate the 2 datatables so that if i filter dtt1, dtt2 filters itself with respect to the firstnames in dtt1?

it is because if i do code like the one suggested, and say i have over 100 records, that will really take time to process.
Nov 21 '07 #4

Shashi Sadasivan
Expert 100+
P: 1,435
Hi,
Sorry about my previous post.
I have been using some third party tools since I plunged into windows apps.
and they have beautiful support for filtering.

Coming back to your query, in your case you might be using a dataView to change the filter.

once the filter is changed, I think the ListChanged Event of the dataview is triggered.

Once you reach here you can check if the row isvisible as mentioned before.

cheers
Nov 21 '07 #5

nev
100+
P: 251
nev
Hi,
Sorry about my previous post.
I have been using some third party tools since I plunged into windows apps.
and they have beautiful support for filtering.

Coming back to your query, in your case you might be using a dataView to change the filter.

once the filter is changed, I think the ListChanged Event of the dataview is triggered.

Once you reach here you can check if the row isvisible as mentioned before.

cheers
hello, actually i already did the code as suggested. what bothers me is that when time comes there are a lot of firstname records, my iterating for loop might take time to process them. is there a way to create a relationship to dtt1 and dtt2 so that dtt2 gets filtered when i filter dtt1? how do you do code to create a relation?
Nov 21 '07 #6

Shashi Sadasivan
Expert 100+
P: 1,435
i think the filter should be of type
FirstName OR firstname2 OR firstname3.....
and not
FirstName AND firstname2 AND firstname3.....

with the AND you may get no items listed.

Seems that the filter you reate will be the same filter for the second table too.
So build a filter string, and assign that to both the datatables!

if you filter table 1 with names fred and jones
then you want table 2 to contain values with names fred and jones.
so the same string should apply.

Hope i got it right
Nov 21 '07 #7

nev
100+
P: 251
nev
oh i forgot to mention i used OR :-)
Nov 21 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.