I am trying to set my report datasource at runtime but it always seems to be recreated each time the report is refreshed. Basically I need to pass some complex parameters into my object's constructor (meaning that using report parameters wont be sufficient as they aren't basic types). I'm using the WinForms viewer and Q1 2016 reporting.
var report = new MyReport();
var ds = new MyReportDataSource();
var objDs = new ObjectDataSource(); // I want to be able to pass some complex parameters here to initialize the object - this is just a trivial example
objDs.DataSource = ds;
objDs.DataMember = "Text";
report.DataSource = objDs;
var reportSource = new InstanceReportSource();
reportSource.ReportDocument = report;
ctl_Report.ReportSource = reportSource;
ctl_Report.RefreshReport(); // This causes the constructor of MyReportDataSource to be called again
I have also tried setting the report.DataSource property to null, which causes the NeedDataSource event to fire - but this doesn't help as even if I set the datasource in the event callback, the constructor of MyReportDataSource gets called AGAIN when calling RefreshReport().
Is there a way to "inject" data into the report without it explicitly calling the constructor of the ObjectDataSource's data member?