Solved

Count rows in filtered datatable

Posted on 2009-05-18
8
1,262 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
  • 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
 
LVL 3

Expert Comment

by:FMabey
ID: 24422361
Is your datatable show in a datagridview or anything? Are you using dataviews?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now