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: 08-28-2014, 12:51 PM
By corygibbons in forum Database
Last Post: 07-11-2007, 08:30 PM
By barbarosa80503 in forum VB Classic
Last Post: 10-28-2005, 03:33 PM
By Michael L in forum VB Classic
Last Post: 11-17-2000, 02:18 PM
By Victor in forum VB Classic
Last Post: 04-07-2000, 05:24 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center