Print Page | Close Window

Total RowCount from GridView using AspDataSource

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=825
Printed Date: 11-Jun-2026 at 3:07am


Topic: Total RowCount from GridView using AspDataSource
Posted By: kmg-pm
Subject: Total RowCount from GridView using AspDataSource
Date Posted: 04-Jun-2008 at 9:30am
Hello,
 
I have an ASP.NET standard GridView bound to an AspDataSource.  I want to retrieve the total row count from the data source.  This is not available from the grid, since I have paging enabled.  Also, I would rather not have to execute a second query just to get the count.
 
I thought about handling the AspDataSource.OnDataBinding event, but none of the event handlers seem to be firing for AspDataSource. 
 
Can I get access to the data directly somehow?  When inspecting, I noticed an AspDataSourceView object.  What is this, and can I get to it?
 
Additionally, if you have any better information and/or samples of using DevForce in ASP.NET apps, that would be great.  The one sample using AspDataSource is pretty bare.
 
Thanks in advance,
-Kevin



Replies:
Posted By: davidklitzke
Date Posted: 04-Jun-2008 at 12:06pm
I wouldn't worry about the cost of getting all of the entities of a given entity type because these entities will likely already be in the cache so performance should be very good.  If you want to, you could also store the total entity count somewhere as a byproduct of performing SelectEntities.


Posted By: kmg-pm
Date Posted: 04-Jun-2008 at 12:30pm
I had tried what you suggested previously, but had some trouble.
 
I have the SelectEntities method in my custom EntityAdapterManager class.   I had created a public property containing the count, and I was setting it in SelectEntities.  Then I tried using the GetAdapterManager method to access this property, but it didn't seem tied to the same instance of my AdapterManager as the EntityQuery was run in.  How could I reference that particular instance?
 
Thanks,
Kevin


Posted By: davidklitzke
Date Posted: 06-Jun-2008 at 8:45am
Why don't you just execute the same code again.  Since I suspect that the entities are already cached, it shouldn't take very long.



Print Page | Close Window