I want to use Globals!PageNumber
in Report body part. How can I access inside Report body?
I am using SQL Server Reporting Service 2008 R2
.
For that you need to use Report variables:
Go to Report Menu
from main Menu in Visual Studio, > Click on Report Properties
> Add new variable - named as PageCount
(Default value to 0)
Then inside header of footer create one textbox and set below expression,
=Variables!PageCount.SetValue(Variables!PageCount.Value+1)
It will automatically increase for each page.
NOTE: Do not hide it from header or footer, the SetValue
will not work if you hide the box, so change the font of textbox to white color. (Do whatever you want but just do not hide it. Then you can use below expression to fetch pagenumber value inside report body.
=Variables!PageCount.Value
I have taken reference from this answer.