Search code examples
asp.netentity-frameworkentitydatasource

EntityDataSource: TotalRowCount returns -1. What's that?


I have an EntityDataSource with OnSelected event (fired after finished query). The event handler has event args of type EntityDataSourceSelectedEventArgs e. Query runs fine without error and the IEnumerable e.Results contains 1 object (I can run through a non-empty foreach-loop) but e.TotalRowCount returns -1.

Does somebody have an idea what this means and what information TotalRowCount actually expresses? How can I determine the number of selected objects if not by using TotalRowCount?


Solution

  • From http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.entitydatasource.selected(VS.100).aspx:

        The TotalRowCount property of the EntityDataSourceSelectedEventArgs 
    object shows the total number of objects in all pages, regardless of the 
    values passed by the data-bound control for paging. 
    
        TotalRowCount is only retrieved if the data-bound 
    control needs it, such as if paging is enabled.
    

    Is your data-bound control using paging?