Finding the row index in a collection of rows

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
 
J

Jim Mitchell

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top