Paging in windows forms

Paging in windows forms

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


mikeclimbs posted on Thursday, August 31, 2006

I noticed the Csla – Web\CslaDataSource supports paging.  Has anyone tried implementing paging for windows using CSLA? 

RockfordLhotka replied on Thursday, August 31, 2006

You can implement paging the same way as in the web - assuming you have a grid control that supports the concept. Most grid controls do support the concept, but only if you switch to a manual mode where you write code to supply the grid with each row of data. This is often called a virtual mode as well.

In CSLA .NET 2.1 there's a new interface, IReportTotalRowCount (currently in Csla.Web, but moving to Csla.Core). You can implement this interface on your collection if you want the collection to only contain a page of data - but still be able to report how many total rows of data are available overall. This is used by CslaDataSource to help implement paging.

You'd probably need similar data when implementing paging in a Windows Forms grid.

glenntoy replied on Friday, September 01, 2006

A followup question for csladatasource, would it be safe to use .NET 2.0 ObjectDataSource if my Csla object is a readonlylist base in web apps?

RockfordLhotka replied on Friday, September 01, 2006

I imagine so.
 
You still need to implement a select method for ODS to call - much like the SelectObject event handler for CDS - so using ODS doesn't save you any code in that regard.
 
Rocky


From: glenntoy [mailto:cslanet@lhotka.net]
Sent: Friday, September 01, 2006 2:01 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Paging in windows forms

A followup question, would it be safe to use .NET 2.0 ObjectDataSource if my Csla object is a readonlylist base?


Lakusha replied on Friday, September 01, 2006

 

BTW, paging is incredibly easy and efficient to implement when using SQL 2005 (or Oracle). The windowing functions make it easier and faster than techniques used with SQL 2000.

Look at the ROW_NUMBER() function in the SQL BOL. Other windowing functions, NTILE(), RANK() and DENSE_RANK() can also be used to acheive different results. It is also quite convenient to use it with a common table expression.

ex:
WITH myrowset as
(Select ROW_NUMBER() OVER(Order by [Name]) as [Num]
        Column1,
         etc.
 From MyTable
 join ...
Where ...
)
Select *
From myrowset
Where [Num] between @nextrow and @nextrow + @pagesize;


 

Copyright (c) Marimer LLC