Hi
I have a report called header.mrt which contains the BusinessObject "User", generated as such:
e.Report.RegBusinessObject ("User", MyUser);
e.Report.Dictionary.SynchronizeBusinessObjects (3);
This report is running just fine. But if used as a Subreport, linked by filename in another Report like so
e.Report.Load ("MainReport.mrt")
e.Report.RegBusinessObject ("User", MyUser);
e.Report.RegBusinessObject ("otherData", MyOtherData);
e.Report.Dictionary.SynchronizeBusinessObjects (3);
there is no data shown in the subreport. What am I doing wrong?
TIA
Martin
Problem with Subreport
-
- Posts: 10
- Joined: Mon Sep 04, 2017 7:44 am
Re: Problem with Subreport
Hello,
Please send us a sample project which reproduces the issue for analysis.
Thank you.
Please send us a sample project which reproduces the issue for analysis.
Thank you.
-
- Posts: 10
- Joined: Mon Sep 04, 2017 7:44 am
Re: Problem with Subreport
OK, here's a sample as a WebSite project.
First create Header.mrt by calling DesignHeader.aspx. This uses a business object of class MyUser . It has a static instance.
Then create MainReport.mrt by calling DesignMainReport.aspx. It too uses MyUser and some other arbitrary data. Now I added a subreport in the designer. This subreport links to the Header.mrt file on my harddisk (you will need to change the file location, btw. I also tried URL linking, didn't work)
If you view MainReport.mrt with ShowMainReport.aspx the Subreport does not contain any data, as if it doesn't know about MyUser...
Thanks
Edit: I can't attach my zip File. Here's the link: https://drive.google.com/a/dynabyte.ch/ ... sp=sharing
First create Header.mrt by calling DesignHeader.aspx. This uses a business object of class MyUser . It has a static instance.
Then create MainReport.mrt by calling DesignMainReport.aspx. It too uses MyUser and some other arbitrary data. Now I added a subreport in the designer. This subreport links to the Header.mrt file on my harddisk (you will need to change the file location, btw. I also tried URL linking, didn't work)
If you view MainReport.mrt with ShowMainReport.aspx the Subreport does not contain any data, as if it doesn't know about MyUser...
Thanks
Edit: I can't attach my zip File. Here's the link: https://drive.google.com/a/dynabyte.ch/ ... sp=sharing
Re: Problem with Subreport
Hello, Martin.
You should register the Business Objects in the sub-report too.
You could do this using the GetSubReport event of the report.
Here is a working code:
Thank you.
You should register the Business Objects in the sub-report too.
You could do this using the GetSubReport event of the report.
Here is a working code:
Code: Select all
public partial class ShowMainReport : System.Web.UI.Page {
protected void Page_Load (object sender, EventArgs e) {
string reportFile = HttpContext.Current.Server.MapPath ("App_Data/MainReport.mrt");
StiReport report = new StiReport ();
report.Load (reportFile);
var cust1 = new Customer ("Test1", "TestCity1", "www.test1.com");
var cust2 = new Customer ("Test2", "TestCity2", "www.test2.com");
var cust3 = new Customer ("Test3", "TestCity3", "www.test3.com");
var list = new List<Customer> { cust1, cust2, cust3 };
//report.RegBusinessObject ("User", MyUser.Current);
report.RegBusinessObject ("Customer", list);
report.Dictionary.SynchronizeBusinessObjects (3);
List<string> assemblies = new List<string> (report.ReferencedAssemblies);
assemblies.Add (System.Reflection.Assembly.GetAssembly (typeof (MyUser)).Location);
report.ReferencedAssemblies = assemblies.ToArray ();
report.GetSubReport += Report_GetSubReport;
StiWebViewer1.Report = report;
}
private void Report_GetSubReport(object sender, StiGetSubReportEventArgs e)
{
string reportFile = HttpContext.Current.Server.MapPath("App_Data/Header.mrt");
StiReport report = new StiReport();
report.Load(reportFile);
report.RegBusinessObject("User", MyUser.Current);
report.Dictionary.SynchronizeBusinessObjects(3);
List<string> assemblies = new List<string>(report.ReferencedAssemblies);
assemblies.Add(System.Reflection.Assembly.GetAssembly(typeof(MyUser)).Location);
report.ReferencedAssemblies = assemblies.ToArray();
e.Report = report;
}
}
-
- Posts: 10
- Joined: Mon Sep 04, 2017 7:44 am
Re: Problem with Subreport
Thanks, this is working nicely
Re: Problem with Subreport
Hello
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.