Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page breaks in subreports are not being respected in autogenerated RDLC code

Tags:

c#

rdlc

I have some C# code which generates some RDLC such as this as a subreport of another report:

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
  <Width>7.5in</Width>
  <Code>
  (some VB scripts go here)
  </Code>
  <rd:ReportID>REDACTED</rd:ReportID>
  <rd:ReportUnitType>Inch</rd:ReportUnitType>
  <Body>
    <Height>3in</Height>
    <ReportItems>
      <Rectangle Name="Zb2f2f8b4ff494d15bc6585b34efb7652">
        <Style>
          <Border />
        </Style>
        <Height>0.125in</Height>
        <Width>7.5in</Width>
        <Top>0.01in</Top>
        <Left>0in</Left>
        <KeepTogether>false</KeepTogether>
        <ReportItems>
            (one and a half godzillion report items go here)
        </ReportItems>
        <PageBreak>
          <BreakLocation>Start</BreakLocation>
        </PageBreak>
        <Bookmark>Zfe6b6d34b3e1409dadd5fd77a1acb08c</Bookmark>
      </Rectangle>
      <Rectangle Name="Zfe6b6d34b3e1409dadd5fd77a1acb08c">
        <Style>
          <Border />
        </Style>
        <Height>0.125in</Height>
        <Width>7.5in</Width>
        <Top>0.26in</Top>
        <Left>0in</Left>
        <KeepTogether>false</KeepTogether>
        <ReportItems>
            (seven to the 9001st power report items go here)
        </ReportItems>
        <Bookmark>Zfe6b6d34b3e1409dadd5fd77a1acb08c</Bookmark>
      </Rectangle>
    </ReportItems>
  </Body>
  <DataSets>
    (some data sets go here)
    </DataSet>
  </DataSets>
  <ReportParameters>
    <ReportParameter Name="Title">
      <DataType>String</DataType>
      <Prompt>ReportParameter1</Prompt>
      <AllowBlank>true</AllowBlank>
      <Nullable>true</Nullable>
      <DefaultValue>
        <Values>
          <Value>Events</Value>
        </Values>
      </DefaultValue>
    </ReportParameter>
    <ReportParameter Name="r19">
      <DataType>String</DataType>
      <Prompt>ReportParameter1</Prompt>
      <AllowBlank>true</AllowBlank>
      <Nullable>true</Nullable>
    </ReportParameter>
    <ReportParameter Name="EventFilter">
      <DataType>String</DataType>
      <Prompt>ReportParameter1</Prompt>
      <AllowBlank>true</AllowBlank>
      <Nullable>true</Nullable>
    </ReportParameter>
    <ReportParameter Name="r51">
      <DataType>String</DataType>
      <Prompt>ReportParameter1</Prompt>
      <AllowBlank>true</AllowBlank>
      <Nullable>true</Nullable>
    </ReportParameter>
  </ReportParameters>
  <Page>
    <PageHeight>11in</PageHeight>
    <PageWidth>8.5in</PageWidth>
    <LeftMargin>0.5in</LeftMargin>
    <RightMargin>0.5in</RightMargin>
    <TopMargin>1in</TopMargin>
    <BottomMargin>1in</BottomMargin>
  </Page>
  <DataSources>
    <DataSource Name="RootModel">
      <rd:DataSourceID>ead9fb2d-33cb-4023-9052-e431eff63ba5</rd:DataSourceID>
      <ConnectionProperties>
        <DataProvider>System.Data.DataSet</DataProvider>
        <ConnectString>/* Local Connection */</ConnectString>
      </ConnectionProperties>
    </DataSource>
  </DataSources>
  <CodeModules>
    <CodeModule>REDACTED.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=REDACTED</CodeModule>
  </CodeModules>
</Report>

However the <BreakLocation> element is not being respected; the page breaks in the report are arbitrary rather than occurring before the specified section. Is there something special I need to do to make page breaks work in subreports?

edit: I added this as the last element in the <ReportItems> collection, to no avail:

<Rectangle Name="Zfdfe94b4111c481abc7df3ca2a2f4f92">
    <Height>0in</Height>
    <Width>0in</Width>
    <Top>0in</Top>
    <Left>0in</Left>
    <KeepTogether>false</KeepTogether>
    <PageBreak>
        <BreakLocation>End</BreakLocation>
    </PageBreak>
</Rectangle>
like image 766
ekolis Avatar asked Dec 10 '19 19:12

ekolis


People also ask

How do I insert a page break in Rdlc?

Right Click on Group1 and select Group Properties. Then select Page Breaks tab in the same window. Check the "Between each instance of Group" and click OK. Now you can see a new column has added to the Table.

How do I remove a page break in SSRS?

If you're trying to display report data in one page, it is simple to do in SSRS. All you have to do is select an entire table and then go to the property pane. Update KeepTogather = True. Show activity on this post.


1 Answers

According to this, it should be possible to add breaks after sub reports with help of Rectangle at the bottom of each SubReport after all rendering objects. The "PageBreak" property should be set to "End". When the SubReport is finished, the Rectangle forces a page break.

like image 182
user2316116 Avatar answered Nov 04 '22 13:11

user2316116