Finding the row index in a collection of rows

  • Thread starter Thread starter Jim Mitchell
  • Start date Start date
J

Jim Mitchell

So that I can find the pageindex in my datagrid, I need to know the index in
a collection of rows where based on a record id. Right now, I have to loop
through the entire collection.

Is there a better way. Thanks in advance.

I tried to figure out the find method, but it seems to be asking for an
object... dsAccounts.Tables(0).rows.find(???)

row_index = 0

For Each drow In dsAccounts.Tables(0).Rows

row_index = row_index + 1

If drow.Item("ID") = returned_id Then Exit For

Next
 
Thats what I was looking for. Thanks!

Prasad said:
Hi

Use

DataView dv = new DataView(dsAccounts,"","ID")
int RowIndex = dv.Find("1001")

HTH
Prasad
index
 
Back
Top