Solved

Count rows in filtered datatable

Posted on 2009-05-18
8
1,347 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Web Form VB.Net  import CSV 4 38
I need help converting a bitmap to an image in VB.Net 1 32
VB.NET (2008) - Refactoring Question 2 21
vb.net help 4 29
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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