Solved

Find the index of a row from a datatable

Posted on 2010-08-31
2
459 Views
Last Modified: 2013-12-25

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)
        SQLConn.Open()
        SQLAdapter = New SqlDataAdapter(strSQL, SQLConn)
        dTable = New DataTable
        SQLAdapter.Fill(dTable)

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

    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.  
0
Comment
Question by:DRRobinson
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
Comment Utility
Based on what information do you want the index ? What do  you want to do with it ?

If you search through the primary key:
http://msdn.microsoft.com/en-us/library/ydd48eyk.aspx
http://support.microsoft.com/kb/305561
0
 

Author Comment

by:DRRobinson
Comment Utility
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!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now