ASP.Net Paging

ASP.Net Paging

Old forum URL: forums.lhotka.net/forums/t/4252.aspx


dantruj posted on Tuesday, January 29, 2008

As stated earlier there are 4 places for paging to be implemented.  Currently I am doing filtering then sorting in the

protected void ContactsListDataSource_SelectObject(object sender, Csla.Web.SelectObjectArgs e) Event.

So here are my questions:

If I do paging in the SelectObject event, do I need to implement the IReportTotalCount interface in my List object?

Since I do filtering and sorting in the SelectObject event, am I forced to do paging there as well instead of doing it in DP_Fetch?

I mean if I have 20 contact records that are populated each time I fill my List (ReadonlyListbase), and 5 of them have last names that start with 'A', but they are not in order in the table, I would want to filter them first before paging.  Because paging would pull the first 10 records thus excluding some of the contact records that have lastnames that begin with 'A'.  Is this correct?

RockfordLhotka replied on Tuesday, January 29, 2008

Yes, if you are going to filter/sort in the UI, then you must page in the UI as well. The three concepts are linked to each other. Well, more precisely, paging is dependent on any filter/sort, so the filter/sort must occur first (at or lower in the stack).

dantruj replied on Tuesday, January 29, 2008

Cool, thank you

dantruj replied on Tuesday, January 29, 2008

If filtering and sorting has to be done first before paging, then if I decide to use a stored procedure to page (only pull needed rows) then do I also have to do sorting and filtering in the stored procedure first?  If that is true, then that defeats the purpose of FilteredBindingList and SortedBindingList while paging.

If I truly want to use the UI to do filtering and sorting, then I am forced to pull All records from the database first, which is a waste, unless I do some sort of cache at the UI.  But this defeats the purpose of just pulling the rows you need.

Please explain how I can filter/sort and page in the SelectObject event while only pulling the records I need from the database (not pulling all records and just returning 10 from the BO)? or is this even possible?

Thanks for help in advance.

Dan T.

 

RockfordLhotka replied on Tuesday, January 29, 2008

The concept of paging is dependent on any filter/sort you apply. So you must filter/sort before you can page the resulting data. It is a logical progression.

 

So yes, you must do the filter/sort before you apply any paging. If you do the paging in the database, then you must do the filter/sort there first.

 

Rocky

 

 

From: dantruj [mailto:cslanet@lhotka.net]
Sent: Tuesday, January 29, 2008 4:23 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] ASP.Net Paging

 

If filtering and sorting has to be done first before paging, then if I decide to use a stored procedure to page (only pull needed rows) then do I also have to do sorting and filtering in the stored procedure first?  If that is true, then that defeats the purpose of FilteredBindingList and SortedBindingList while paging.

If I truly want to use the UI to do filtering and sorting, then I am forced to pull All records from the database first, which is a waste, unless I do some sort of cache at the UI.  But this defeats the purpose of just pulling the rows you need.

Please explain how I can filter/sort and page in the SelectObject event while only pulling the records I need from the database (not pulling all records and just returning 10 from the BO)? or is this even possible?

Thanks for help in advance.

Dan T.

 



Copyright (c) Marimer LLC