Paging a Repeat Region with simple Previous and Next links

OK, so we're familiar with creating a Repeat Region, but what if we don't want to display all the records at once, but still want the user to be able to cycle through them? We need to using 'paging' to split the data onto a number of pages, and create Previous and Next buttons.

Let's create a page with some dynamic data (I'll leave you to do that bit on your own) and apply a Repeat Region from the Server Behaviors panel.

We'll choose to only display five records at a time, as we don't want the page to get too long.

Click OK, and you'll see the Repeat Region applied to the page. What we need to do now is to create an item to be our Previous and Next links. I'm going to use simple text links, but you could use images as links if you liked.

I've decided to use "Next »" as my Next link, and "« Prev" as my Previous link - so I'll insert these under my Repeat Region.

In order to make these into active links I must highlight each one and apply a Server Behavior to them. I'll start with the Next link.

The Server Behavior we need to apply is called "Move To Next Record" and is under the "Recordset Paging" section in the Server Behaviors menu.

You'll see the Move To Next Record dialogue box, which looks like this

Be sure to check that the correct Recordset is selected, and click OK

Once done, you will see that your Next link turns blue, indicating that it is now a dynamic element. (the color is lost in the screenshot due to compression!)

You need to repeat the process for the Previous link, but this time selecting the Server Behavior called "Move To Previous Record"

Click OK and you will see that now both your links are dynamic elements. You can hit F12 and check them out if you like!

There's just a couple more things that we need to do. At the moment, the Next link will be displayed even if we're at the end of the recordset. In the same way, even when we're right at record number 1, the Previous link is displayed.

That's not very user friendly, so what we're going to do is have those links hidden in the circumstances where they just don't make sense.

Highlight your Next link, and apply the "Show Region If Not Last Record" Server Behavior, under the Show Region category.

We need to now do the same with the Previous link, but this time selecting the "Show Region If Not First Record" option. This will only show the Previous link if the current record not is the first one in the recordset.

Click OK and that should be it! You document will show both links in blue, as they are dynamic elements, and they will both be flagged as "Show If..." regions.

It's as simple as that. You could now experiment with some of the other Server Behaviors in the "Recordset Paging" menu. See if you can create a link to move to the last record in the recordset, and one to return to the first record. If you're feeling particularly adventurous, you could have a play with the Move To Specific Record server behavior. Go on! It's fun!