Conditional Visibility and Page Breaks with SQL Server 2005 Reporting Services


I know there's a bug with conditional visibility and page breaks with SQL 2005, but I wonder if anyone has come up with a work around.

I have a table that has a conditional visibility expression, and I need a page break at the end of the table.

  • If I set the PageBreakAtEnd property to true. It is ignored no matter what. Remove the visibility condition and it works.
  • If I place the table inside a rectangle with the conditional visibility on the table, and the page break on the table. Same result. The page break property is ignored.
  • If I set the rectangle with the PageBreakAtEnd property and the table with the visibility condition, then I still get a page break even when the table isn't shown.

Any other ideas on what to try? I'm almost at the point where I need a separate report rather than conditional visibility 🙁

Edit: @Josh: That has the same problems. If the second table has conditional visibility it doesn't work. If it doesn't have the visibility expression, then I get the page break all the time.

@Erick: I really wanted that to be the answer but unfortunately it doesn't work. When the visibility expression evaluates to hidden, there's a big gap where the rectangles would be (which I can live with), and when it evaluates to visible, the page breaks still don't work.

Best Solution

Place two rectangles, one inside the other.
Place your table inside the inner rectangle and set it to always be visible.
Set the inner rectangle's Page Break to Insert After Rectangle.
Set the outer rectangle's visibility to use your conditional expression.

The page break and the conditional visibility are now separated, and the inner rectangle's page break won't be processed if it is not visible, but it will if it is visible.

Edit: When I tried this, it did not appear to work in the Preview tab in Visual Studio, but it did work in the Print Preview and when I exported the report to PDF.