how to find row position after sorting dataview table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I set a dataview to a table. Then I bind a currencyManager to the dataview.
I can iterate through the dataview no problem so far. Then I sort the
dataview on a certain field and rebind the currencyManager to the dataview.
I can still iterate through the newly sorted dataview OK. The problem is
that the row order of the underlying table did not change with the sort. Now
the rows are out of order if I want to set a datarow object to the currently
displayed row.

How can I determine what row I am on after doing a sort on a dataview?

Thanks,
Rich
 
Nevermind, I figured it out:

Dim drF() As DataRow
drF = myDataset.Tables("myTable").Select("rowID = " & txtRowID.Text)
dr = drF(0)

rowID is the unique column in myTable. I use the Select method of the
DataTable object to retrieve all rows that have the given RowID (which will
be 1 row in my case since RowID is unique). I collect the returned rows in a
DataRow array, drF. Then I set a datarow object to the first row in drF(0).
 
Back
Top