Click here to Skip to main content
16,016,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private int SubreportTotelPage(CrystalReportViewer CrvViewer)
 {
   int TotalPage = 0;
   ReportDocument reportDocument = ((ReportDocument)CrvViewer.ReportSource);
  Sections sections = reportDocument.ReportDefinition.Sections;
  foreach (Section section in sections)
      {
        ReportObjects reportObjects = section.ReportObjects;
            foreach (ReportObject reportObject in reportObjects)
            {
               if (reportObject.Kind == ReportObjectKind.SubreportObject)
                 {
                   SubreportObject subreportObject = (SubreportObject)reportObject;
                            if (subreportObject.SubreportName == "Sub_Memorandum.rpt")
                            {
 CrystalDecisions.CrystalReports.Engine.TextObject rptTxtGroup = subReportDocument.ReportDefinition.ReportObjects["Text9"] as CrystalDecisions.CrystalReports.Engine.TextObject;
                                if (rptTxtGroup != null)
                                    return TotalPage = Convert.ToInt16
(rptTxtGroup.Text.ToString());

                         /*       CrystalDecisions.CrystalReports.Engine.FieldObject rptFieldGroup = (subReportDocument.ReportDefinition.ReportObjects["{@NoofPageinSubReport}"] as CrystalDecisions.CrystalReports.Engine.FieldObject);
                                if (rptFieldGroup != null)
                                    return TotalPage = Convert.ToInt16(rptFieldGroup.ToString()); */
                                else
                                    return TotalPage;
}

In Report preview report Function NoofPageinSubReport show correct value ie 6
but the C# function return text "@NoofPageinSubReport"

when i am using CrystalDecisions.CrystalReports.Engine.FieldObject
it return "@NoofPageinSubReport" text ... ie
WhilePrintingRecords;
Shared numberVar TotalPageSubreport;
TotalPageSubreport:=PageNumber as out put.
Posted
Updated 17-Jan-13 7:02am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900