In this article, I will show you how to implement custom paging in SQL server 2008. I used ROW_NUMBER() in where clause to achieve ms sql paging.
Create a stored procedure with parameters currentindex and pagesize and name it as tbl_customerPaging with the below following code. You can implement paging in gridview with the help of stored procedure by passing the index of the pageindex as parameter.
Stored procedure with parameters:
ALTER PROCEDURE [tbl_customerPaging]
(
@CurrentIndex int,
@PageSize int
)
AS
SELECT * FROM(
SELECTROW_NUMBER()over(order by customerId) AS RowId,
ContactName
FROM Customers
)AS A
WHERE RowId BETWEEN (@CurrentIndex -1) * @PageSize+ 1
AND (@CurrentIndex * @PageSize )
Post your comments / questions
Recent Article
- How to add two numbers in Android Studio? | Source Code
- FindViewByID returns null in android studio -SOLVED
- Saving changes is not permitted in SQL SERVER - [SOLVED]
- Restore of database failed. File cannot be restored over the existing. -[SOLVED]
- One or more projects in the solution were not loaded correctly in Visual Studio 2019 | FIXED
- How to find Laptop's Battery Health?
- SOLVED-Related Field got invalid lookup: icontains error in Django
- How to enable Search Feature in Django admin?
Related Article