Recordset Paging - Page 15
August 14,2002
So far we have displayed our categories dynamically. When a category
is clicked the user is taken to a complete list of all books associated with
the respective category. Thus far we only have 20 different records to display
in total – this is easy to deal with, but what about in future, when we want
to display lots more? Also bear in mind that when we add the thumbnail images,
they will increase the page loading time even further, so it will eventually
become unmanageable to display all the records for each category every time.
So what if we wanted to remedy this by say, displaying 4
records at a time? This is all no problem at all – that's what the Recordset
Paging set of behaviors is for.
Displaying a Few Records
At a Time
Let's make some adjustments to our books.asp page by having
only 4 records display at a time. Before we go any further we have to edit
our repeat region. Double-click the Repeat
Region behavior listed in the Server
Behaviors list from the Application
Panel. This will re-open the dialog box that selects our Repeat Region parameters. Instead of showing
all records check the radio button above it and show 4 records at a time. Hit OK.
Move To Previous Record
Place your cursor in a suitable place (we chose a place
in the second column of the first row of your table) and select Server
Behaviors > + > Recordset Paging > Move To Previous Record, which should bring
up the following dialog box:
Leave the value for the Link field the way it is; it will create the
text for us. Make sure the rsBooks
recordset is selected in the Recordset
field and hit OK. The Previous hyperlink will be added to your page
where you put your cursor.
Move To Next Record
Choose another suitable space (we chose a space just to
the right of the Previous hyperlink) and select Server Behaviors > + > Recordset
Paging > Move To Next Record,
and click OK. A Next hyperlink will be added to the right of
our Previous hyperlink.
Before we view the page in our browser, let's use an Application
Object called the Recordset Navigation
Status. This object creates a display of how many records exist and
how many are being displayed currently. It shows the user where he or she
is in the context of all the records collectively. Before we add it, let's
make some room for it by adding a third row above the row that contains the
Previous and Next links. Do this by placing your cursor
in the first row, right-clicking, and selecting Table > Insert Row – an empty row should be created
above the other two.
Now that we have created the empty row place your cursor
in the second column of the first row. Select Insert > Application Objects > Recordset Navigation Status, and OK the dialog box that appears, to add the
object to our page. Now when we view the books.asp page in a browser we should see something like this:
Although the page looks great, there is one slight problem
that needs fixing – did you notice it? The problem is that when you get to
the detail page, the Previous hyperlink
is displayed even though there are no previous records (when records 1-4 are
displayed). In addition, when you scroll through the records and get to records
12-16, the last group of records, the Next hyperlink is still displayed.
What we really want to happen is for the Previous link to show only if you are not at the first record, and the Next link to show only if you are not at the last record. Well guess what?
Dreamweaver MX has another group of server behaviors that do this for us!
They can be found under Server Behaviors
> + > Show Region.
Detail Page(Cont.) - Page 14
Dynamic Dreamweaver MX
Show Region - page 16
|