Solved

Count rows in filtered datatable

Posted on 2009-05-18
8
1,490 Views
Last Modified: 2012-06-21
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
Comment
Question by:jdhackett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 1

Expert Comment

by:Modar_Hijazi
ID: 24411213
Try
dtAagedDebt.DefaultView.RowFilter.Count()

;) ;)
0
 
LVL 1

Author Comment

by:jdhackett
ID: 24411905
Em, no that won't work.
I take it that your smileys meant you knew this!
0
 
LVL 1

Author Comment

by:jdhackett
ID: 24422030
Still stuck on this. Anyone got a solution?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 3

Expert Comment

by:FMabey
ID: 24422361
Is your datatable show in a datagridview or anything? Are you using dataviews?
0
 
LVL 1

Author Comment

by:jdhackett
ID: 24423491
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
 
LVL 3

Expert Comment

by:FMabey
ID: 24429177
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
 
LVL 1

Author Comment

by:jdhackett
ID: 24448703
I filter using:
stFilter = "AgeOfDebt >= 90"
dtAgedDebt.DefaultView.RowFilter = stFilter


0
 
LVL 1

Accepted Solution

by:
jdhackett earned 0 total points
ID: 24448796
Found it! I'd have to do
dtAgedDebt.DefaultView.Count

Seems obvious now. Thanks anyway
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question