Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 23rd, 2004, 09:22 AM
Authorized User
Join Date: Aug 2003
Location: , , .
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.


Reply With Quote
  #2 (permalink)  
Old November 23rd, 2004, 10:48 AM
Authorized User
Join Date: Aug 2003
Location: , , .
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")

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 04:07 PM.

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