Print Page | Close Window

DataList paging

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=8552
Printed Date: 29 March 2026 at 12:01pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: DataList paging
Posted By: Boecky
Subject: DataList paging
Date Posted: 04 January 2004 at 11:37am
I'm finding out how to use paging with a datalist. I found an example
http://www.dotnetbips.com/displayarticle.aspx?id=115 - http://www.dotnetbips.com/displayarticle.aspx?id=115
What you guys think of this code? Maybe someone has more experience in it and more examples? thanks



Replies:
Posted By: Mart
Date Posted: 04 January 2004 at 11:53am
If its an SQL Server database your binding it to i would use a stored procedure like this:


CREATE PROCEDURE dbo.GetDocuments
@PageSize int,
@PageNumber int
AS
DECLARE @Ignore int
DECLARE @LastID int
 
IF @PageNumber > 1
  BEGIN
        /* For pages > 1 compute how many records to ignore,
        set ROWCOUNT and SELECT ID into @LastID */
        SET @Ignore = @PageSize * (@PageNumber - 1)
        SET ROWCOUNT @Ignore
        SELECT @LastID = ID
         &nbs p;     FROM Documents
         &nbs p;     ORDER BY ID DESC
  END
ELSE
  BEGIN
        /* For page #1 just set rowcount to pagesize */
        SET ROWCOUNT @PageSize
  END
 
/* Set rowcount to @PageSize and
SELECT page for output (note the WHERE clause) */
SET ROWCOUNT @PageSize
      SELECT *
         &nbs p;   FROM Documents
         &nbs p;   WHERE ID < @LastID
         &nbs p;   ORDER BY ID DESC
SET ROWCOUNT 0
GO


Mart.


Posted By: Boecky
Date Posted: 04 January 2004 at 12:03pm
Thanks anyway, but I'll use an access db


Posted By: Mart
Date Posted: 04 January 2004 at 12:16pm
You can use the same method that i told you before (with the repeater control) with a datalist.


Posted By: Boecky
Date Posted: 06 January 2004 at 4:11am

for who's interested, this site is really great, a clear explaination of the PagedDataSource class, for using paging with datalist and repeaters.

http://www.charon.co.uk/content.aspx?CategoryID=28&ArticleID=21 - http://www.charon.co.uk/content.aspx?CategoryID=28&Artic leID=21




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net