ekolis
ekolis

Reputation: 6766

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

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>

Upvotes: 6

Views: 561

Answers (1)

user2316116
user2316116

Reputation: 6824

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.

Upvotes: 2

Related Questions