• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

Find the index of a row from a datatable

I need to be able to find the index of a particular row.  I have the follwoing code:

    Private Sub frmPermitEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        StatusBarNavInfo = "Displaying 1 of " & RecordCount & " permits found"
        StatusBar.Items(0).Text = StatusBarNavInfo

        SQLConn = New SqlConnection(SQLConnString)
        SQLAdapter = New SqlDataAdapter(strSQL, SQLConn)
        dTable = New DataTable

        DR = dTable.Rows(0)
        TotalRowCount = DR.Table.Rows.Count

    End Sub

Open in new window

How can I find the index of a datarow.  I want to allow my users to navigate, similar to a datacontrol with bound controls.  
1 Solution
Based on what information do you want the index ? What do  you want to do with it ?

If you search through the primary key:
DRRobinsonAuthor Commented:
Well, I figured out a method to accomplilsh my goal.  As soon as the for loads that displays the data from the first row, I set a Module level variable to 0.   Then when a next or previous button is pressed, I just increment and decrement the currently displayed row index.  Then set that new index to the module level variable.  works great.  Thanks for the quick response!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now