*/
Got something to write about? Check out our Article Builder.

Other Views

corner
*/

ADONET FAQ - Navigating Through Records

How do I navigate through the records?

Navigating through the records is again very easy. For the Next button, we have written the following simple event handler

 
Private Sub btnNext_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnNext.Click
        currRec += 1
        If currRec >= totalRec Then
            currRec = 0
        End If
        FillControls()
End Sub
Here we first increment the integer variable currRec and check if it has crossed the last record (using the totalRec variable) in the table. If it has, then we move the current record to the first record. We then call the FillControls() method to display the current record on the form. Similarly the event handler for the Previous button looks like this:

 
Private Sub btnPrevious_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnPrevious.Click
        currRec -= 1
        If currRec < totalRec Then
            currRec = totalRec - 1
        End If
        FillControls()
End Sub


Here we decrement the currRec variable and check if has crossed the first record and if it has then we move it to the last record. Once again, we call the FillControls() method to display the current record. Now you can navigate through the records using the Next and Previous buttons. http://www.programmersheaven.com/articles/images/faq/image009.gif

Back
corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.