Efficient GridView Paging... not quite getting it
I'm trying to wrap my head around custom pagi开发者_如何学Gong in the ASP.NET Gridview, but all of the examples I read seem to be bloated with stuff I don't need (Scott Gu's for example).
Can someone point me in the right direction to a tutorial that is easy to understand the basics?
EXAMPE: If I have the following Stored Procedure...
Alter Procedure dbo.GetReqeusts
@Category nvarchar(50)
As
Begin
Select dbo.[Name],
dbo.[ID]
From dbo.[Table]
Where dbo.[Category] = @Category
End
And this example returns 200 rows, how would I convert this Stored Procedure into an efficient paging procedure?
4guysfromrolla.com have a whole series of articles about working with and displaying data. There are several about custom paging.
The key point for the stored procedure is to use the ROW_NUMBER()
function to restrict the records to be returned:
SELECT RowNum, [Name], [ID]
FROM
(SELECT [Name], [ID]
ROW_NUMBER() OVER(ORDER BY [ID]) as RowNum
FROM [Table] t
WHERE [Category] = @Category
) as DerivedTableName
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1
精彩评论