views:

122

answers:

2

How do I split data into pages on ASP.Net?

I'm looking for something like what Google does when you have too many search results and it splits them into x number of pages.

+5  A: 

It would depend entirely on the content. If it's a simple datagrid you can use the built in datagrid paging. If the data is coming from SQL though, I'd advise building a generic "paging control" and using the paging functionality of SQL to only pull back the data you want to see.

If it's SQL 2005 (or above) paging is nice and easy:

SELECT  Description, Date
FROM     (SELECT  ROW_NUMBER() OVER (ORDER BY MyCol DESC) AS Row, Desc, Date FROM MyTable)
AS MyTableWithRowNumbers
WHERE  Row >= 1 AND Row <= 10
Steven Robbins
A: 

A paginating datagrid or a repeater would be your best options.

Eppz