public class ClassA{
public string Property1 { get; set; }
public string Property2 { get; set; }
List<ClassB> ListClassB { get; set; }
List<ClassC> ListClassC { get; set; }
}
public class ClassB{
public string Property3 { get; set; }
public string Property4 { get; set; }
List<ClassD> ListClassD { get; set; }
}
public class ClassC{
public string Property5 { get; set; }
public string Property6 { get; set; }
public string Property7 { get; set; }
}
public class ClassD{
public string Property8 { get; set; }
public string Property9 { get; set; }
public string Property10 { get; set; }
}
Hello everyone,
The issue here is that I need to create the report using .rdlc
reports from an object that has a structure similar to ClassA
. Currently, I've only been able to create a 'master-detail' report only considering the properties from ClassA
and ClassB
This was achieved from next sources:
https://www.c-sharpcorner.com/article/rdlc-subreport-using-c-sharp-and-wpf/
https://www.youtube.com/watch?v=2-YkNo1Os3Y
But now, I haven't been able of including the data from ClassC
using the same approach, since there is no way for setting the datasources for the 3rd level.
Any guidance, or source for solving this issue is always welcomed.
Jsimon
Update
I made a quick and small prototype which implements a report with two levels. For the 2nd level, the only thing we need to do is to implement the SubreportProcessing
event. Here is the code.
private void LoadApplicationsCatalog()
{
using (IdentityDataContext context = new IdentityDataContext())
{
this.reportViewer1.LocalReport.DataSources.Clear();
var applicationsCatalog = context.spGetApplicationsCatalog().Select(a => new { a.IdentityApplicationCatalogId, a.Name, a.IdentityApplicationId }).ToList();
this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ApplicationCatalog", applicationsCatalog));
this.reportViewer1.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing;
this.reportViewer1.Refresh();
this.reportViewer1.RefreshReport();
}
}
private void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
int identityApplicationId = Convert.ToInt32(e.Parameters[0].Values[0]);
using (IdentityDataContext context = new IdentityDataContext())
{
var applications = context.IdentityApplications.Where(a => a.IdentityApplicationId == identityApplicationId).ToList();
ReportDataSource datasource = new ReportDataSource("Application",applications);
e.DataSources.Add(datasource);
}
var applicationCatalogReport = (LocalReport)sender;
}
Unfortunatly, I haven't found a way for filling up the datasources for a third level.
After several days, I found this How to process subreport of a subreport in rdlc? which helped me to solve the creation of reports with 3 or more levels.