Asp. NET Data List control page summary (ii) using stored procedure paging

Source: Internet
Author: User

When the data volume of the database is relatively large and the execution efficiency is higher, we can consider using the stored procedure to implement paging, returning the data table that needs to be displayed according to the number of pages passed in, select only the data of the current page. (This is much more efficient than using PagedDataSource classes.) )

Now uses repeater to implement a data paging, the database uses the SQL server2000, uses inside the system table Northwind.

The new stored procedure is as follows:

Create PROCEDURE dbo.mypaging
(
@pagesize int,
@currentPage int,
@total int output
)
as CREATE TABLE #temp
(
ID int identity (1,1),
CustomerID varchar (m),
CompanyName varchar (
), ContactName varchar (m),
contacttitle varchar,
Phone varchar ()
)
insert INTO #temp ( Customerid,companyname,contactname,contacttitle,phone)
Select Customerid,companyname,contactname, Contacttitle,phone from
Customers
Select @total = (select count (*) from Customers)
declare @startID int< C21/>declare @endID int
Set @startID = (@currentpage-1) * @pagesize +1
Set @endID = @currentpage * @pagesize
SELECT * from #temp where id>= @startID and id<= @endID
Go

If you do not write stored procedures, you can refer to the Web site online raw page stored procedures: http://www.webdiyer.com/AspNetPager/utility/sqlspgen.aspx

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.