Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 23rd, 2004, 09:22 AM
Authorized User
Join Date: Aug 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting value of filtered datagrid row

I have a datagrid that contains a large list of names and numbers. I have given the user a search box above the datagrid that filters the datagrid as such:

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

        Dim aFilter As String
        Dim aRows As Integer

        If txtSearch.Text.Trim = "" Then
        aFilter = ""
            aFilter = "SortName Like '" & txtSearch.Text & "*'"
        End If

        dsSCSOEmployees.Tables("Personnel").DefaultView.Ro wFilter = aFilter
    End Sub

This works fine...the problem comes when I try to get the value of the row that the datagrid has been filtered down to. For instance, let's say in my dataset the first record is Abner and I filter down to Duke. I try to retrieve the value like this:

selectedName = frm.dataset.Tables(0).Rows(frm.datagrid.CurrentRow Index).Item("SortName")

The problem is that selectedName will be Abner because it's still trying to get the value of row one which IS Abner, but I want the value of the row I've filtered down to, which is Duke.

I know I'm not saying this as clearly as I could, but it's driving me crazy and I'm desperate to find an answer.

Thanks in advance for any help.


Old November 23rd, 2004, 10:48 AM
Authorized User
Join Date: Aug 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts

Once again, I've finally resolved the problem myself through trial and error. In case someone else is having similar trouble in the future, this is what I did:

selectedName = frm.dataview(frm.datagrid.CurrentRowIndex).Item("C olumnName")

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrollbar in row of Datagrid Except Header Row Theone84 ASP.NET 2.0 Professional 0 August 11th, 2008 12:10 AM
Filtered Sharepoint list, not filtered in infopath wmrdude SharePoint Development 0 July 26th, 2006 05:09 AM
Manage data row by row in datagrid Dragonist Classic ASP Databases 5 July 29th, 2004 04:17 AM
One Row in DataGrid error petersonginae VB.NET 2002/2003 Basics 2 July 14th, 2004 05:14 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.