title: How to Display Page Number in Report Body of SSRS 2008 R2?
body: <p><strong><em>I think a lot of developers are facing the problem of try to display page numbers by using SSRS 2008 R2</em>.</strong></p>
  
  <p>There is an alternative solution <strong>which requires SSRS 2010 + version</strong>. Otherwise you will get 1 all the time.</p>
  
  <p>Go to <strong>"Report"</strong> -> <strong>"Report Properties"</strong> -> <strong>"Code"</strong></p>
  
  <p>In the <code>Custom Code</code> section, enter the following:</p>
  
  <pre><code>Public Function PageNumber() as String
       Dim str as String
       str = Me.Report.Globals!PageNumber.ToString()
       Return str
  End Function
  
  Public Function TotalPages() as String
       Dim str as String
       str = Me.Report.Globals!TotalPages.ToString()
       Return str
  End Function
  </code></pre>
  
  <p>Now you will be able to access these functions anywhere in the report (header, body, or footer). So, to output the page number and total pages in a textbox located in the body simply enter this for the value:</p>
  
  <pre><code>="Page " + Code.PageNumber() + " of " + Code.TotalPages()
  </code></pre>
  
  <p><strong><a href="http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c2047eee-41a8-4d79-ae58-dbf60f6e7554/page-number-records-number?forum=sqlreportingservices" rel="noreferrer">This</a> solution DOES NOT work with SSRS 2008 R2.</strong></p>
  
  <p>However there is a workaround, it will work with any version higher than <code>2008 R2</code> (include 2008 R2). I will post as an answer, hope it will help some people whoever struggling with this issue.</p>