Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ObjectDataSource Total Row Count (HOW?!) [modified]

ObjectDataSource Total Row Count (HOW?!) [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpalgorithmsquestionasp-netcom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dwatkins dirq net
    wrote on last edited by
    #1

    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,

    Dirk Watkins

    Z 1 Reply Last reply
    0
    • D dwatkins dirq net

      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,

      Dirk Watkins

      Z Offline
      Z Offline
      Ziltard
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • Z Ziltard

        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

        D Offline
        D Offline
        dwatkins dirq net
        wrote on last edited by
        #3

        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.

        Dirk Watkins

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups