JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Navigating in Datasets

As discussed in the In Depth section of this chapter, you can use a BindingContext (see the previous topic) object's Position property to move through a dataset, setting the current record that simple-bound controls are bound to and display. In the DataBinding example on the CD-ROM, I used this property to display the current location in a dataset and to navigate through the dataset.


Main Page

Displaying the Current Location

In the DataBinding example, I displayed the current location in a label, like this:

Label1.Text = ((Me.BindingContext(DataSet11, "authors").Position + _
    1).ToString + " of ") & Me.BindingContext(DataSet11, _
    "authors").Count.ToString

Main Page

Moving to the Next Record

To move to the next record in the DataBinding example, I increment the Position property (this property won't increment if we're at the end of the dataset):

Me.BindingContext(DataSet11, "authors").Position = _
    Me.BindingContext(DataSet11, "authors").Position + 1

Main Page

Moving to the Previous Record

To move to the previous record in the DataBinding example, I decrement the Position property (this property won't decrement if we're at the beginning of the dataset):

Me.BindingContext(DataSet11, "authors").Position = _
        Me.BindingContext(DataSet11, "authors").Position - 1

Main Page

Moving to the First Record

To move to the first record in the DataBinding example, I set the Position property to 0:

Me.BindingContext(DataSet11, "authors").Position = 0

Main Page

Moving to the Last Record

To move to the last record in the DataBinding example, I only have to set the Position property to the total count of the records in the dataset minus one:

Me.BindingContext(DataSet11, "authors").Position = _
    Me.BindingContext(DataSet11, "authors").Count - 1
Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor