Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - DataList paging
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DataList paging

 Post Reply Post Reply
Author
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post Topic: DataList paging
    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
What you guys think of this code? Maybe someone has more experience in it and more examples? thanks
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post Posted: 04 January 2004 at 12:03pm
Thanks anyway, but I'll use an access db
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Boecky View Drop Down
Groupie
Groupie
Avatar

Joined: 23 December 2002
Location: Belgium
Status: Offline
Points: 110
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boecky Quote  Post ReplyReply Direct Link To This Post 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&Artic leID=21

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.