Dom84
Dom84

Reputation: 864

Reportviewer (RDLC), hide a row on the first page

Is there a way to trigger the row visibility depending on the page number?

i need to show a grant total at the beginning of a table and a subtotal at the end of every page, but the subtotal only, if the report will be greater than 1 Page.

I tried with some code execution on the footer / header section and store the PageNumber, because Globals!PageNumber isn't accessible from the body. But no effect, seems the footer and header section is created later so my variable in the report code is always 0 while reading it in the table row hidden expression.

How could this be done? Any different ideas how to hide a table row on first page?

Upvotes: 1

Views: 2119

Answers (1)

InitK
InitK

Reputation: 1281

Similar to re-setting page number in this post, you can add custom code to check what page you are on and then call setPageNumber function from the header for first page only and checkIfFirstPage function in Visibility Expression for your row:

Shared pageNumber as Integer

Public Function setPageNumber()
  pageNumber = 1
  Return newPage
End Function

Public Function checkIfFirstPage() as Boolean
  Dim isFirstPage as Boolean
  If (pageNumber = 1)
      isFirstPage = true
      pageNumber = pageNumber + 1
  Else
      isFirstPage = false
  Endif
  Return isFirstPage 
End Function

To add custom code, open Report properties window, Code tab:

enter image description here

To call setPageNumber from report header on first page only - you can add small text box in the header and set it to display white on white (so it won't show the value). Set the expression of the text box to:

= IIF(Globals!PageName = 1, Code.setPageNumber(), 0)

Another approach to your problem is to use Variables and text box in the header similar to this post.

Upvotes: 2

Related Questions