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 restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
- The request was aborted: Could not create SSL/TLS secure channel -Error in Asp.net
- FieldError: Cannot resolve keyword 'id' into field in Django project
- How to hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
Related Article