Wrox Programmer Forums
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 29th, 2009, 08:53 AM
Authorized User
Join Date: Mar 2007
Posts: 52
Thanks: 6
Thanked 2 Times in 2 Posts
Default Paging in listview, using paging in stored procedures

Has anyone successfully used a ListView control instead of a GridView in theBeerHouse, and maintaining the paging used in the stored procedures?

Just hooking it up to a DataPager control would, in theory, mean that all records would be retrieved, which is not the meaning in theBeerHouse. (I say "in theory", because I haven't been able to compile and test the things I have tried so far)

My idea was to somehow set the value for PageSize and PageIndex in the ObjectDataSource, from the values in the DataPager, based on a buttons CommandValue, or from a number in the NumericPagerField.

I noticed that the ObjectDataSource has the "MaximumRowsParameterName" and "StartRowIndexParameterName" properties, which can be used when paging is enabled.

These would be set to PageSize and PageIndex, as parameters for ex. GetArticles right? Is it possible to set these parameter values based on the values from the DataPager, and keep track of them in ViewState?

Any ideas?

Old January 30th, 2009, 10:54 AM
Lee Dumond's Avatar
Wrox Author
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts

Yes, I've replaced the GridView in the ArticlesListing.ascx user control.

It is a little tricky replicating the exact behavior of the GridView (making the pager disappear when all records are displayed; doing the location highlighting, resetting the page index) but it is all doable. I plan to write a blog post or two on the ListView in the very near future.

Fortunately however, server-side paging is not tricky at all.

If you have an ObjectDataSource with paging enabled = true (you do) and the Select method you indicate for it has paging parameters named startRowIndex and maximumRows (it does), then you are all set.

The DataPager has read-only properties named StartRowIndex and MaximumRows. Their values will automatically be passed to the ODS Select method as arguments for the startRowIndex and maximumRows parameters. You don't have to do this manually at all. (In fact, you can't, because the buttons in the DataPager do not have CommandValues, only CommandNames.)

DataPager values are also automatically tracked in ViewState.
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

if (this.PostHelpedYou)

Last edited by Lee Dumond; January 30th, 2009 at 11:51 PM..
The Following User Says Thank You to Lee Dumond For This Useful Post:
philthy (February 15th, 2009)
Old November 11th, 2012, 07:03 PM
Authorized User
Join Date: Feb 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

I'm interested in replacing my GridViews with ListViews, did you ever get round to writing the blog post your mentioned, or can you share how to do this?


Similar Threads
Thread Thread Starter Forum Replies Last Post
DB recordset paging using ajax paging? kumiko Classic ASP Basics 0 May 26th, 2008 10:23 AM
Paging fadyratl VB Databases Basics 0 December 27th, 2006 05:04 AM
paging folders solomon_13000 Classic ASP Professional 1 May 28th, 2006 09:12 AM
Problem with my paging... fung Classic ASP Databases 2 August 23rd, 2004 07:43 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.