Reset Page Number in RDLC Report by group

别来无恙 提交于 2019-12-11 02:51:20

问题


This seems like it should be simple enough. I have a report that has Tablix in it that has groups by Customer forces a page break between groups. I want the page numbers to be per customer, so the pages would be like so:

Customer1 Page 1/2
Customer1 Page 2/2
Customer2 Page 1/1
Customer3 Page 1/4
etc, etc

I can't seem to find a way to reset the page numbers or cause the total pages to be total pages for the group.


回答1:


It looks like this can't be done, at least in VS 2012. I was able to get it working in an RDL for SSRS, then I opened that RDL and found the relevant section

<Group Name="MemberId">
  <GroupExpressions>
    <GroupExpression>=Fields!MemberId.Value</GroupExpression>
  </GroupExpressions>
  <PageBreak>
    <BreakLocation>StartAndEnd</BreakLocation>
    <ResetPageNumber>true</ResetPageNumber>
  </PageBreak>
</Group>

I then brought that back to my RDLC and inserted the <ResetPageNumber>true</ResetPageNumber> into my group. When I opened the file again in VS showed the following error.

Deserialization failed: The element 'PageBreak' in namespace
'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' 
has invalid child element 'ResetPageNumber' in namespace 
'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'. 
List of possible elements expected: 'BreakLocation' in namespace 
'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' 
as well as any element in namespace '##other'. Line 1812, position 20.

End result, I'm moving the report to Reporting Services.




回答2:


It can be done actually, but not without adding some custom code to the report:

Shared reportGroup as String
Shared newPage  as Integer

Public Function ResetPageNumber(newGroup as String)
  If Not (reportGroup = newGroup)
    reportGroup = newGroup 
    newPage  = 1
  Else
    newPage  = newPage  + 1
  End If
  Return newPage
End Function

Then in the footer, add text box for page number and make it's value:

= Code.ResetPageNumber(ReportItems!TextBoxWithYourGroupNameOrID.Value)


来源:https://stackoverflow.com/questions/23300494/reset-page-number-in-rdlc-report-by-group

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!