views:

519

answers:

4

I'm using the Repeater control on my site to display data from the database. I need to do pagination ("now displaying page 1 of 10", 10 items per page, etc) but I'm not sure I'm going about it the best way possible.

I know the Repeater control doesn't have any built-in pagination, so I'll have to make my own. Is there a way to tell the DataSource control to return rows 10-20 of a much larger result set? If not, how do I write that into a query (SQL Server 2005)? I'm currently using the TOP keyword to only return the first 10 rows, but I'm not sure how to display rows 10-20.

+2  A: 

This isn't a way to page the data, but have you looked into the ListView control? It gives the flexibility of repeater / data list but with built in paging like the grid view.

And for paging in sql, you would want to do something like this

Darren Kopp
+3  A: 

You have to use the PagedDataSource, it allows you to turn a standard data source into one that can be paged. Here's an example article

jonezy
A: 

This was answered here.

Eric Z Beard
A: 

@jonezy

I wish I could accept both your answer and Darren's. They were both VERY helpful!

Josh Hinman