Hi !
I'm working with MS Reporting Services. The underlying datasource is
IEnumerable<MyObject>
, I'm not using DataSets.
Every MyObject
has properties and some other IEnumerable
collections.
In the report I want to display all the properties from MyObject
and
the collections lists too.
I didn't know how to display this inner collections, so I've made a SubReport to which I passed the MyObject
.Id so that the SubReport could retrieve the object by himself and Build a the DataSource for these inner collections.
I do this in this event.
myReportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
private void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
int id;
if (e.Parameters.Count > 0 && int.TryParse(e.Parameters[0].Values[0], out id))
{
MyObject current = myObjects.Where(x => x.MyObject.Id == id).FirstOrDefault();
InnerListBindingSource.DataSource = current.InnerCollection;
e.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource(
"MyInnerCollectionDataSource", InnerListBindingSource));
}
}
But there is always "The SubReport could not be shown" in my Master Report. (Master report - subreport are correctly binded)
Any Idea why? Or how to resolve this in a more elegant way ?
Thank you