Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Could you please help me in finding a solution. I don't want to loop through each datarow in the result data returned from dataview.rowfilter. I have a datatable and I use this to filter for the desired rows:
datatable.defaultview.rowfilter = "selective condition"

I want to retrieve the result into a new dataview( call it newview) and then I can filter for another collection of rows with another condition like this newview.rowfilter = "..."

Hope you understand my problem. I don't want to use combined conditions (to pass to the rowfilter of the original defaultview).

Any help is greatly appreciated.

Thank you very much!
Posted
Updated 25-Oct-11 0:52am
v2
Comments
Slacker007 25-Oct-11 6:53am    
Edit: readability and formatting.

1 solution

Use DataView.ToTable[^]:

DataTable dt = (some query expression);
dt.DefaultView.RowFilter = " ... ";
DataTable dt2 = dt.DefaultView.ToTable();


Note that this will copy the data. But I think that that has to happen for any solution to your problem, because you want to leave the initial table intact and not use a combined filter expression (which would be how you would create a double-filtered view without copying data).
 
Share this answer
 
Comments
[no name] 26-Oct-11 18:13pm    
Thank you very much!
That's exactly I wanted, but now I don't know how to assign the new dataview the the datatable.defaultview (because this is readonly), I have to choose the solution using combined conditions. If you know how to assign the new dataview to the defaultview, please let me know. Anyway, thank you very much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900