Add custom navigation and paging information for the DataGrid customization page
Source: Internet
Author: User
datagrid| pagination in the last article I talked about customizing the DataGrid page, this avoids getting the entire data recordset to display a single page of data, thereby increasing paging efficiency, but using a digital connection or a simple previous page with a DataGrid, the next page, And you can't see the total number of pages, total records, and so on information. Here's what we need to add to the section.
First look at the modified pagination display, screenshots are as follows:
(Figure I)
The data source used is the same as the custom paging of the DataGrid control in ASP.net, which is access to the Northwind library, and for the sake of independence here's a list of stored procedures,
CREATE PROCEDURE [Getcustomersdatapage]
@PageIndex INT,
@PageSize INT,
@RecordCount INT out,
@PageCount INT out
As
SELECT @RecordCount = COUNT (*) from Customers
SET @PageCount = CEILING (@RecordCount * 1.0/@PageSize)
DECLARE @SQLSTR NVARCHAR (1000)
IF @PageIndex = 0 OR @PageCount <= 1
SET @SQLSTR =n ' SELECT top ' +str (@PageSize) +
' CustomerID, Companyname,address,phone from Customers order by CustomerID DESC
ELSE IF @PageIndex = @PageCount-1
SET @SQLSTR =n ' select * FROM (select top ' +str (@RecordCount-@PageSize * @PageIndex) +
' CustomerID, Companyname,address,phone from Customers to CustomerID ASC ' temptable ORDER by CustomerID '
ELSE
SET @SQLSTR =n ' select Top ' +str (@PageSize) + ' * FROM (select top ' +str (@RecordCount-@PageSize * @PageIndex) +
' CustomerID, Companyname,address,phone from Customers to CustomerID ASC ' temptable ORDER by CustomerID '
The above code is relatively simple, also do not need to analyze, if there is any good suggestions or problems can be in the blog message, very happy to communicate with you.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service