Solved

Record Count on Search Results

Posted on 2006-10-26
2
208 Views
Last Modified: 2010-04-23
Hi

I have some code that searches on various fields on an Access DB. Everything works fine, however I would like to populate a label with the number of records found.

This is my code for the search:

Private Sub txtSearch_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged

        Dim dvFilter As DataView = Nothing

        If TypeOf dgAssets.DataSource Is DataView Then
            dvFilter = CType(dgAssets.DataSource, DataView)
        ElseIf TypeOf dgAssets.DataSource Is DataTable Then
            dvFilter = CType(dgAssets.DataSource, DataTable).DefaultView
        End If

        If txtSearch.TextLength > 0 And RBEFCAssetTAG.Checked = True Then
            dvFilter.RowFilter = "EFCRef LIKE '" & txtSearch.Text & "*'"
        ElseIf txtSearch.TextLength > 0 And RBUser.Checked = True Then
            dvFilter.RowFilter = "User LIKE '" & txtSearch.Text & "*'"

        Else
            dvFilter.RowFilter = ""
        End If

        dgAssets.DataSource = dvFilter

    End Sub

Thanks
0
Comment
Question by:weight01
2 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
Comment Utility
dvFilter.Count should contain the number of records in the dataview after the filters have been applied.
0
 
LVL 1

Author Comment

by:weight01
Comment Utility
Thanks ZeonFlash, your help is appreciated, that worked fine.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

7 Experts available now in Live!

Get 1:1 Help Now