John the Ripper
John the Ripper

Reputation: 2439

Show total number of pages in an RDLC report toolbar

I have several reports using MS ReportViewer. The reports are showing the standard ReportViewer toolbar. On this toolbar is a page navigation section with back and forward buttons and the number of pages. For my reports they when the report first loads it always shows the number of pages as such:

1 of 2?

The question mark means it hasn't calculated the total number of pages yet and if you navigate to the last page this number will update. But I would like to have this report the total page count without the user having to navigate to the last page.

I looked around the RDLC properties and couldn't find any settings for this.

Upvotes: 8

Views: 10238

Answers (4)

Shubham Jain
Shubham Jain

Reputation: 1

The question mark means that the total page number displayed is not the actual page count, but an estimate. The VS2010 report viewer control by default generates the total page count as an estimate to improve performance.

So you can write below line into your code after you add data source to report.

ReportViewer1.PageCountMode = new PageCountMode();

ReportViewer1 is ID of my report view control.

Upvotes: 0

Bernd at New Orleans
Bernd at New Orleans

Reputation: 121

There is the property called PageCountMode with the default - Estimate, you can set as Actual

Upvotes: 0

aleafonso
aleafonso

Reputation: 2256

Another "cleaner" way to do it:

The question mark means that the total page number displayed is not the actual page count, but an estimate. The VS2010 report viewer control by default generates the total page count as an estimate to improve performance. If you like, you can change the page count mode to actual mode using ReportViewer.PageCountMode property.

Source: http://social.msdn.microsoft.com/Forums/en-US/3070efeb-2eb1-4e16-a9d6-9ec8ecb36d94/reportviewer-page-controls-show-page-1-of-2-how-to-remove-question-mark?forum=vsreportcontrols

Upvotes: 7

Shakti Prakash Singh
Shakti Prakash Singh

Reputation: 2533

You can add a textbox to the header and footer and set it to Globals!TotalPages. This will force the ssrs engine to process all the pages at the same time. You can hide the textbox though.

Hope this helps.

Upvotes: 8

Related Questions