How to get PageNumber in body of RDL?

  • How to get PageNumber in body of RDL?

    ny ideas?

    Thanks

    -Meghna

  • In Code window add following function

    Public Function nPageNumber() as string

    dim str as String

    str = me.Report.Globals!PageNumber.ToString()

    Return str

    End Function

    ==============

    Call in table body section with the hepl of this line

    =Code.nPageNumber()

    ============

    Enjoy 🙂

  • I also have the same problem.If I use the code mentioned the value returned is always 1.

    Not sure why

  • Use Following expression

    ="Page No. " + cstr(Globals!PageNumber) + " of " + cstr(Globals!TotalPages)

    Good Luck

    Sandip Shinde

  • hi sandeep,

    we don't wan't just to print page number the issue is we want this globle varialble of pagenumber inside table, body section... any idea???

  • These Global Variables can be used only in the page header and page footer. 🙂

  • Hi Sandeep,

    Is there any way to hold the Page Number from the Page Footer using a shared variable, so that it can be used in the Body of the RDL to incorporate some of the functionality?

    Thanks !

    - Ansuman

  • @Ansuman,

    I'm still figuring this out, it seems that page footers are processed only after the body.

    I put a textbox that uses Code.TestFunction() in a table in the body and in the footer

    The one in the body called TestFunction once for every row as expected, but the footer called the function only after everything else, not in between the body rows, unfortunately. So storing the page number from the footer in a variable does not seem to be an option.

    Oh yeah, I used a Dim variable at first to check in what order the functions were called, but you cannot use that between body and footer - It seems that the Dim variables are cleaned up after the body is processed so if you want to test it using a variable, use Shared variables.

    (some background info)

    I'm trying to make certain report items visible and invisible based by comparing the page number to a stored page number - in fact a "Page header" but with data fields in it.

    If I can get a reference to the page number I know it's possible..

    Did any of you find a solution for this?

    Edit: Well, it seems only the last post here was recent. I'll just share a thread on this subject that pretty much concludes this discussion.

    link

    It explains that it is not possible to get pagenumbers in the body and why; there is also an interesting read there about processing flow of headers and footers.

  • You should be able to limit the number of records per page, and then do your visibility calculation based on the record number.

  • @Meghna

    I also tried the shared variable and Dim variable concept, but each time it returned 1 and 0 respectively, probably the reason behind it may be that the Body is executed first followed by header and footer, and it tries to reset the PageNumber build in variables when the body is executed, and the reason the for this is what you stated.

    Following approach worked for me:

    I tried to fix the no of rows per page say about 11 rows and used an equation

    Pseudo code : code.GetCount(RowNumber("<Tablix Name>"))

    Function GetCount(a as int64)

    If a mod 11 = 1 then

    .......

    .......

    .......

    End if

    End Function

    So what it did is, on every row number that is a multiple of 12, I was able to implement the requirement.

    My requirement was to make a textbox of a table visible on start of every page.

    I tried this and it worked for me.

    - Ansuman

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply