Solved

Count rows in filtered datatable

Posted on 2009-05-18
8
1,302 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 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

20 Experts available now in Live!

Get 1:1 Help Now