I have Report1.mrt with a ReportTitleBand having a text on it (Lets call it title from now on), a DataBand having two CrossDataBands. This report works perfectly when used directly.
I have Report2.mrt that just has a Sub-Report component referring to Report1.mrt.
I can't get Report2 to properly show the report having Sub-Report referring to Report1.mrt. Note that I have followed the suggestion from this link (viewtopic.php?t=55698) to properly register the Business Objects in the sub-report by using GetSubReport event.
Following conditions occur:
1) Works well when Sub-Report refers to a Page (Manually imported from a .pg file saved from Report1) which is something I am not looking for.
2) When Sub-Report is linked to Report1.mrt file the title text is shown but no Databands are showed and GetSubReport event is not fired at all.
3) When Sub-Report is linked to nothing GetSubReport event is fired three times (just once if I remove the code inside Rep_GetSubReport!) but nothing appears on report2, not even the title. My code is mentioned below:
Code: Select all
private async void btnShowReport(object sender, StiGetSubReportEventArgs e)
{
List<Component> myData = await GetDataAsync();
StiReport rep = new StiReport();
rep.Load("Reports/Report2.mrt");
rep.RegBusinessObject("Component", myData);
rep.Dictionary.SynchronizeBusinessObjects(2);
List<string> assemblies = new List<string>(rep.ReferencedAssemblies);
assemblies.Add("Data.dll"); // Containing Component class definition.
rep.ReferencedAssemblies = assemblies.ToArray();
rep.GetSubReport += Rep_GetSubReport;
rep.Show();
}
private async void Rep_GetSubReport(object sender, StiGetSubReportEventArgs e)
{
if (e.SubReportName.StartsWith("SubReport1"))
{
List<Component> myData = await GetDataAsync();
StiReport rep = new StiReport();
rep.Load("Reports/Report1.mrt");
rep.RegBusinessObject("Component", myData);
rep.Dictionary.SynchronizeBusinessObjects(2);
List<string> assemblies = new List<string>(rep.ReferencedAssemblies);
assemblies.Add("Data.dll"); // Containing Component class definition.
rep.ReferencedAssemblies = assemblies.ToArray();
e.Report = rep;
}
}