How to get total count of rows in DetailsView?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to get total count of rows in DetailsView?

  1. #1
    Join Date
    Sep 2006
    Posts
    13

    How to get total count of rows in DetailsView?

    Current situation:

    • A DataSet connecting to a SQL Server and creating TableAdapters
    • One of the TableAdapters looks at the username of the logged on user and filters the records by user ID
    • A DetailsView on an aspx page that uses an ObjectDataSource to display that user's records


    Project requirements include displaying the total number of records associated with that user in a label. Right now, I'm using a separate call to the database to do a record count and then populating the label with that info. The separate data call would seem to be unnecessary IF there is a way to look at the DetailsView to determine the number of records it currently contains. I've already tried:

    • Me.DetailsView.Rows.Count - always returned a 19 even when I verified there were 0 or 3.
    • Me.DetailsView.PageCount - always returned a 0, regardless
    • Me.DetailsView.DataItemCount - always returned a 0


    Any ideas?

    Thanks,

    John

  2. #2
    Join Date
    Sep 2006
    Posts
    13
    Figured it out. This is working:

    Protected Sub NewTasksDetailsView_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewTasksDetailsView.DataBound
    Me.lblNewTasks.Text = "Unreviewed tasks: " & Me.NewTasksDetailsView.DataItemCount.ToString
    End Sub

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Thanks for posting your solution. Hopefully it will help someone else.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. how to count the total rows in datagrid
    By relan8 in forum VB Classic
    Replies: 5
    Last Post: 08-28-2014, 12:51 PM
  2. Query works in Access, but not VB .NET
    By corygibbons in forum Database
    Replies: 6
    Last Post: 07-11-2007, 08:30 PM
  3. need to return total record count, but here is the trick...
    By barbarosa80503 in forum VB Classic
    Replies: 2
    Last Post: 10-28-2005, 03:33 PM
  4. How to count rows in DBgrid/DataGrid
    By Michael L in forum VB Classic
    Replies: 2
    Last Post: 11-17-2000, 02:18 PM
  5. MSHFlexGrid: Get Total for Rows and Columns
    By Victor in forum VB Classic
    Replies: 1
    Last Post: 04-07-2000, 05:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center