Paging design recommendation for asp.net and sqlserver 2005

▼魔方 西西 提交于 2019-12-05 19:50:14

You may be interested in this... Paging of Large resultset in asp.net

I would suggest you create a stored procedure to query and page your data. Linq To SQL is a fast an easy way to execute the stp.

Simple example of stored procedure to take care of paging:

CREATE PROCEDURE [dbo].[stp_PagingSample]
(
    @page int,
    @pagesize int
)
AS

WITH Numbered AS
(
    SELECT *, ROW_NUMBER() OVER (ORDER BY ID) AS 'RowNumber'
    FROM tbl_YourTable
) 
SELECT * 
FROM Numbered
WHERE RowNumber BETWEEN ((@page - 1) * @pagesize) + 1 AND (@page * @pagesize);

The stored procedure is the tricky part. But drop a comment if you would like me to add more sample code executing the stp and rendering the data... :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!