Solved

Import Subreport Data Programmatically

Posted on 2011-03-25
10
984 Views
Last Modified: 2012-05-11
I have a report file that I am sending values to and storing in text objects at runtime in my code. This report is being used as a subreport in my main report file. I have this subreport added to the main report but when the pdf is created, the subreport is blank and not showing the values that I sent to it.

How can I get the subreport to import the values I stored in it via code at runtime?
0
Comment
Question by:FIM2003
  • 5
  • 5
10 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 35216641
How are you exporting the report?

If it is through the viewer then I don't think you can.

You could export through your own code and pass the values to the subreport then export and that should work.

mlmcc
0
 

Author Comment

by:FIM2003
ID: 35216701
Sending values to reportSummary (subreport) and exporting report (main report) to a PDF at the end of the code with:

report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Statement");

Open in new window


However, I'm not sure what should go above that to ensure the report receives all of the values I sent to the reportSummary.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35216784
How are you calling the viewer?

The code should be the same except for calling the export rather than the viewer

mlmcc
0
 

Author Comment

by:FIM2003
ID: 35216833
Not using a viewer. The code just passes parameters to the report and some additional data to the subreport file and then exports the pdf.

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35216942
How are you passing the information to the subreport?

Is the subreport set to reimport on open?

mlmcc
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:FIM2003
ID: 35217272
Here is some of the code for how I am passing different information to each of the reports. I'm just including a few lines as examples since it's nearly all of the same, just multiple variables.

The subreport does have "Re-import When Opening" enabled.


private CrystalReportBill report = new CrystalReportBill();
private BillSummary reportSummary = new BillSummary();

CrystalDecisions.CrystalReports.Engine.TextObject lblBalanceDue = ((CrystalDecisions.CrystalReports.Engine.TextObject)reportSummary.Balance.ReportObjects["lblBalanceDue"]);
lblBalanceDue.Text = String.Format("{0:C}", row["Amount_Due"]);

report.SetParameterValue("@cwid", id);
report.SetParameterValue("@begdate", begDateCR);
report.SetParameterValue("@enddate", endDateCR);

report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "BillingStatement");

Open in new window

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35217336
Turn off the reimport.

Where are you opening the subreport in the code?

mlmcc

0
 

Author Comment

by:FIM2003
ID: 35217354
Okay, that was originally disabled but I enabled it to try when it was originally not working.

The summary (subreport) is being added in the Report Header.
0
 

Author Comment

by:FIM2003
ID: 35217451
Oh, whoops sorry. Read right over the "in the code."

The subreport is being created before the Page_Load:

public partial class BillMonth : System.Web.UI.Page
{
        string id;
        private CrystalReportBill report = new CrystalReportBill();
        private BillSummary reportSummary = new BillSummary();
        
        protected void Page_Load(object sender, EventArgs e)
        {

Open in new window

0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 35217760
Is BillSummary the subreport?

You need to open it as a subreport object not as its own report.

mlmcc
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now