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 & "*'"
dsSCSOEmployees.Tables("Personnel").DefaultView.Ro wFilter = aFilter
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.