Data row question

  • Thread starter Thread starter Nikolay Petrov
  • Start date Start date
N

Nikolay Petrov

How to find a row number in a datatable?

I know how to iterate through rows in table using:

dim row as system.data.datarow
for each row in DataSet1.tables(table_index).rows
'statemens
next

But i want to find the row number which my statement currenlty is working
on.

TIA
 
There is no way to find the index of a give datarow, other then going
through the datatable looking for it.

You can also add a column to keep track of the row's index, but that means
keeping it up to date during inserts, etc.
 
You can also use an iteration in the For Each loop or use
me.bindingcontext(theDataSet, "The Table").position. Keep in mind that this
is 0 based so you would need to add 1.

Hope this helps.
 
Can I use this somehow to find row number or something similiar
Dim tbl As System.Data.DataTable
Dim i As Integer
Dim j As Integer
For i = 0 To tbl.Rows.Count - 1
If (tbl.Rows(i).Item(0)) = "something" Then
j = i
End If
Next
 

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

Back
Top