ObjectDataSource Total Row Count (HOW?!) [modified]
-
I've been searching on this for a while and haven't found anything. How can I get the total row count from an ObjectDataSource control made up of a generic list of custom objects? I tried doing casting the
e.ReturnValue
to my generic object list in the ObjectDataSource Selected event to no avail:(( List < Product > )e.ReturnValue).Count
Has anybody done this before? I just want to show the user how many products are in a certain category along side the GridView. I'm using C# .NET 2.0 and have a Data Access Layer doing custom paging and sorting like this article on 4GuysFromRolla. Thanks, -
I've been searching on this for a while and haven't found anything. How can I get the total row count from an ObjectDataSource control made up of a generic list of custom objects? I tried doing casting the
e.ReturnValue
to my generic object list in the ObjectDataSource Selected event to no avail:(( List < Product > )e.ReturnValue).Count
Has anybody done this before? I just want to show the user how many products are in a certain category along side the GridView. I'm using C# .NET 2.0 and have a Data Access Layer doing custom paging and sorting like this article on 4GuysFromRolla. Thanks,Don't know if this is exactly what you're searching for, but did you check http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectcountmethod.aspx
-
Don't know if this is exactly what you're searching for, but did you check http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.selectcountmethod.aspx
The ObjectDataSource.SelectCountMethod Property just gives the name of the method to get the SelectCount.. I want the actual select count. :) Here's some more information: I am getting the e.ReturnValue from the ObjectDataSource Selected event. The ObjectDataSource is hitting a Data Access Layer that returns a List of Products:
public static List GetProducts(int maximumRows, int startRowIndex, string sortExpression, int categoryId) ...
I'm only getting the records I need from the database by page with this DAL method. I'm then using a ObjectDataSource SelectCountMethod to get the total number of products in that category (ALL pages):public int TotalNumberOfProducts(int categoryId, string sortExpression) ...
The thing I really want is to get the value of the TotalNumberOfProducts in that category without hitting the database again. I should be able to get that from the ObjectDataSources Selected event or is there somewhere else where I should be trying to get this value? Any suggestions would be very helpful! Thanks.