Link to home
Start Free TrialLog in
Avatar of jdhackett
jdhackettFlag for Ireland

asked on

Count rows in filtered datatable

I have a Data Table, dtAgedDebt. It has 52 rows.
If I apply a filter to it, how would I get the number of filtered rows?
For example:
? dtAagedDebt.DefaultView.RowFilter
"AgeOfDebt >= 120"
? dtAgedDebt.Rows.Count
52

There are only 8 rows that meet the filter requirements - how would I find them and get the count?
Thanks
Avatar of Modar_Hijazi
Modar_Hijazi

Try
dtAagedDebt.DefaultView.RowFilter.Count()

;) ;)
Avatar of jdhackett

ASKER

Em, no that won't work.
I take it that your smileys meant you knew this!
Still stuck on this. Anyone got a solution?
Is your datatable show in a datagridview or anything? Are you using dataviews?
No, its not. I need to so some calculations on the filtered rows, and just need to count them.
How would a dataview help?
I just wondered how you filter the data?

I'm assuming you want to look at the data table and just count the number of rows which meet the criteria?
I filter using:
stFilter = "AgeOfDebt >= 90"
dtAgedDebt.DefaultView.RowFilter = stFilter


ASKER CERTIFIED SOLUTION
Avatar of jdhackett
jdhackett
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial