Force a page break inside an RDLC Table

Ever wanted to force an RDLC layout to print a page break dynamically when YOU require it?
Well, it took me some time, but here is a solution/work around to get there.
Let’s begin with the origin of my problem. I am currently converting multiple classic reports to an RDLC layout. (Yay!)

Here I ran into some nice functionality of a previous partner. On text lines of the sales quote they could use a few predefined Standard Text Codes to do formatting. Such as TXTB, TXTBU, etc. (Bold, Bold Underlined, etc.). These are actually no issue to using them in RDLC. Simple add more rows and set the hidden property accordingly. (Hard coded, as was done in classic for this example…).

One of the allowed properties gave me a little headache though. That property was “NEWPAGE”.

Now, this is actually pretty easy in classic, just call CurrReport.NEWPAGE and your set to go. RDLC does not have such a property…

I started by creating an integer in classic increasing it as I run into the NEWPAGE property. Then passing it to RDLC allowed me to play around with it.
With it, I made a group with no header/footer, but with the property “New page after group”. This actually works pretty good, BUT also starts a new page ALWAYS after my table. For me, not really an issue, but the customer didn’t really like it, which is logical off course.

Some browsing around the internet and such showed me numerous options for a new page after a number of lines (also by using groups). But 1 post in particular spoke of adding a rectangle which also has a property “New page before/after rectangle”. In this case, the table was put inside the rectangle to keep it together on certain conditions. But gave me an idea none the less.

First I created a new row, and set the hidden property correctly to the “NEWPAGE” value. Then in 1 of the fields, I added a rectangle and set the property “New page after Rectangle”.

Well, It appears that either the property does not work inside a table or does not work at all. So I was off to a next solution again. Which, sadly, I didn’t find anymore.

Then I saw the rectangle looked like the body of the report itself containing a grid. I thought: what the hell, let’s just try some stuff. Inside the rectangle, I dropped another rectangle, reset the settings of the parent rectangle, and set the child rectangle property with the “new page after rectangle” Boolean. I saved my report and ran it. After the run, I had to look twice to make sure my eyes were not lying, but behold, the report was actually printing a page break whereI had wanted it to print it.

I really didn’t want to think about why it suddenly did print. I was just happy to deliver another finished report to my customer.

I literally spend a lot of time finding a solution on the internet. Where most sites told me it was impossible, 1 site offered me a step in the good direction. A bit of playing around, again, helped me to the final solution.
Maybe not a perfect solution, but at least workable and sort of clean.

Good luck to all other needing this kind of thing. I hope that I have been a bit helpful at least.

*UPDATE*: Please read this follow up post.

6 thoughts on “Force a page break inside an RDLC Table

  1. This method works!!!! But I have some trouble: I inserted rectange with pagebreak in group footer, and after running report groups with multiple rows splited on several pages first page with some rows and last page with 2 rows and pagebreak, this repeats on every group. How I can resolve this problem?

      • What if i want to show one complete information on each page of a person. Mean if there is data of two person then at first page it should show person1 and on 2nd page person2 data.

        • That depends on how your data is set up, if you only have “person” information, the easiest way is to tell the table to create a page per record, this is possible by just using properties.

          If it always is 1 person but with header data which is similar and also requires a new page per record, you could make your table size, the size of a page, so it always starts on a new page.
          If it has a variable length, you could opt to use a rectangle with a page break before as described in the post.

  2. Hi Magno,

    Just wanted to note that here is something with blog, the Links\Other Blogs\etc. column overlaps the text.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.