• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1902
  • Last Modified:

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
0
jdhackett
Asked:
jdhackett
  • 5
  • 2
1 Solution
 
Modar_HijaziCommented:
Try
dtAagedDebt.DefaultView.RowFilter.Count()

;) ;)
0
 
jdhackettAuthor Commented:
Em, no that won't work.
I take it that your smileys meant you knew this!
0
 
jdhackettAuthor Commented:
Still stuck on this. Anyone got a solution?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
FMabeyCommented:
Is your datatable show in a datagridview or anything? Are you using dataviews?
0
 
jdhackettAuthor Commented:
No, its not. I need to so some calculations on the filtered rows, and just need to count them.
How would a dataview help?
0
 
FMabeyCommented:
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?
0
 
jdhackettAuthor Commented:
I filter using:
stFilter = "AgeOfDebt >= 90"
dtAgedDebt.DefaultView.RowFilter = stFilter


0
 
jdhackettAuthor Commented:
Found it! I'd have to do
dtAgedDebt.DefaultView.Count

Seems obvious now. Thanks anyway
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now