how to find row position after sorting dataview table

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
 
G

Guest

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top