I have a populated DataTable (dtFleet) with FleetID as the Primary Key.
Based on user selection in a combo box, I am able to locate the row of my DataTable by:
Dim RowFind as DataRow = dtFleet.Rows.Find(x)
I realize I could return values of other fields here, but I already have a routine which populates text fields based on:
Dim RowPosition as Integer = 0
'I use the following for MoveFirst, MovePrevious, MoveNext, MoveLast buttons
Private Sub ShowCurrentRecord()
If dtFleet.Rows.Count = 0 then
me.ClearScreen() 'Sub clears screen if datatable is empty
txtFleetName.Text = dtFleet.Rows(RowPosition)("FleetName").ToString()
txtFleetAdd1.Text = dtFleet.Rows(RowPosition)("Add1").ToString()
'Loads all fields
If I can just get the row position/index based on this other selection, I can use this same routine to populate the fields for the user.
SO, How do I return the row position/index into my RowPosition variable after locating the row in my DataTable which contains the selected Primary Key?