How to get total count of rows in DetailsView?
- 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
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
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
By relan8 in forum VB Classic
Last Post: 09-07-2013, 08:57 AM
By corygibbons in forum Database
Last Post: 07-11-2007, 09:30 PM
By barbarosa80503 in forum VB Classic
Last Post: 10-28-2005, 04:33 PM
By Michael L in forum VB Classic
Last Post: 11-17-2000, 03:18 PM
By Victor in forum VB Classic
Last Post: 04-07-2000, 06:24 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL