.NET DataView find row index from ToTable.Select

706 views Asked by At

I have some code that finds a bunch of rows based on a search criteria and then finds the index of one of those rows. This works fine with a DataTable

Dim drRows() As System.Data.DataRow = dt.Select(vstrSearchCriteria)
If drRows.Length > 0 Then
    Dim intIndex As Integer = Me.Rows.IndexOf(drRows(0))

However, I'm trying the same on a DataView but I can't seem to relate the identified rows back to the DataView - there is no .IndexOf and even iterating through doesn't seem to match the ToTable row with the original Row.

NB the search criteria can be complex and isn't based on keys

Dim drRows() As System.Data.DataRow = dv.ToTable.Select(vstrSearchCriteria) 

For i As Integer = 0 To dv.Count - 1 
    If dv(i).Row is drRows(0) Then

I need to find the dv(x).Row that is the row found by the .totable.select

Many thanks

0

There are 0 answers