how to get row if in datatable?

S

Sean

I need to modify a datatable. I am wondering how to get the datatable row
index number? assuming I have a column 0 whose entry is unique.

Thanks.
 
J

Jim Mitchell

Does this help....

dgUsers.DataKeyField = "ID"

key = dgUsers.DataKeys(dgUsers.SelectedIndex).ToString()
 
J

Jim Mitchell

But the find method returns a datarow, not the row index of the rows
collection as per the help file shown below. So how do you get the
RowIndex"

Private Sub FindInMultiPKey(ByVal myTable As DataTable)
Dim foundRow As DataRow
' Create an array for the key values to find.
Dim findTheseVals(2) As Object
' Set the values of the keys to find.
findTheseVals(0) = "John"
findTheseVals(1) = "Smith"
findTheseVals(2) = "5 Main St."
foundRow = myTable.Rows.Find(findTheseVals)
' Display column 1 of the found row.
If Not (foundRow Is Nothing) Then
Console.WriteLine(foundRow(1).ToString())
End If
End Sub
 

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
474,266
Messages
2,571,073
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top