Get count from llblGenDataSource or GridView

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 27-Oct-2008 18:35:42   

Hi there,

I'm binding a llblGenDataSource2 to a GridView. Its doing everything automatically and paging is enabled. How do I retrieve the total row count so I can describe the results with a label?

Is it possible to get it off of the GridView?

Cheers, Ian.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Oct-2008 05:19:09   

Is paging is server-side, then you should set yourLLBLGenDS.LivePersistence = false, then intercept the events PerformSelect, PerformWork and PerformGetDBCount. At PerformGetDBCount handler you could catch the number you are looking for in a variable to show. (see this for more info).

If the pagination is client-side, a yourLLBLGenDS.EntityCollection.Count should be sufficient.

David Elizondo | LLBLGen Support Team
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 28-Oct-2008 16:08:01   

Its a read only grid so I can just set LivePersistence to false. But this seems like a strange design. Why should when I do db work have anything to do with how I get the row count? And what would I do if I wanted LivePersistence to be true and still page on the server? Does that mean that I wouldn't be able to retrieve the row count?

I currently have LivePersistance true with server side paging and I can see from the profiler that its doing a count(*) of the records. Surely there could just be a property to get this value?

Cheers, Ian.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 28-Oct-2008 18:44:57   

If LivePersistence is set to false, fetching data and saving data isn't performed by the LLBLGenProDataSource2 control

Oh I see. Well I'm using the LLBLGenProDataSource2 to save me from doing the queries manually. So how can I get the row count when LivePersistence is set to true?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 28-Oct-2008 22:08:37   

You could use adapter.GetDbCount with the same filter that the grid uses to get the count before you start.

Matt

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 29-Oct-2008 01:08:56   

Do you mean do my own seperate count?

If so then I think I will just forget the row count as a matter if principle.

Please could you add a row count property onto the LLBLGenProDataSource2 ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 29-Oct-2008 10:22:40   

It is in the code, but not public. It's one of the few small design glitches which need updating. flushed The total number of rows is reported back to the caller of ExecuteSelect on the control, which is the bound grid.

At the moment, if you want it to, you have to write the few lines of code in the code behind to obtain the value and use livepersistence = false. How to do that is in the documentation (just a few lines of code, nothing special)

Frans Bouma | Lead developer LLBLGen Pro
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 29-Oct-2008 18:51:52   

Ok its working. stuck_out_tongue_winking_eye

Its really great being able to generate a list page by ultimately just specifying the entity factory to use.

I've also put my datagrid columns into a seperate user control for each entity. So when loading the list view page, I just give it a key which is uses to look up the user control and the entity factory to use.

Cheers, Ian.