?
Solved

Count rows in filtered datatable

Posted on 2009-05-18
8
Medium Priority
?
1,575 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

770 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