Using the Download Repeat Region Server Behavior

 by Tom Muck

The Download Repeat Region Server Behavior is used to generate a CSV file or a text file from a recordset. This has many uses, including being able to get data from your site remotely, or providing a client with access to their raw data as a CSV file. Here's how it's used:

1. Put your recordset on the page. As a matter of common practice you should only specify the columns in your SQL statement that you want to include in the CSV file. In this example, I'll create a recordset named rs and use the following SQL:

SELECT Title, Author, Category FROM Books

2. Put your columns that you want to download on the page. I usually
separate them with commas and quotation marks, and then put a line break at the end, like this:


The page in design view would look like this:

3. Apply a repeat region to the whole area showing all records. If you
browse the page at this point it will display in one line across the screen,
but if you view source, you'll see it formatted as text.

4. Apply the Download Repeat Region to the entire area and give your
downloaded recordset a filename, like "books_table.csv"

5. Browse the page and you will be able to download the entire recordset.

Here is how the sample data will look from the above example:

"Oracle: A Beginner's Guide","database","30.00"
"Creating Killer Interactive Web Sites : The Art of Integrating Interactivity and Design","web","39.99"
"The Practical SQL Handbook","database","40.12"
"SQL Server 6.5 Second Edition","database","60.00"

Download the sample data from the live example here.

tom muck