I am trying to pass a model to the report using typeReportResource to set it as its dataSource, am I doing this wrong?
This is my Controller
public class ReportViewerController : Controller
{
private IOrganisationLogic _organisationLogic;
public ReportViewerController(IOrganisationLogic organisationLogic)
{
_organisationLogic = organisationLogic;
}
public ActionResult Index()
{
var organisation = _organisationLogic.GetOrganisation();
var typeReportSource = new TypeReportSource();
typeReportSource.TypeName = typeof(OrganisationSample).AssemblyQualifiedName;
typeReportSource.Parameters.Add(new Parameter("flag", true));
typeReportSource.Parameters.Add(new Parameter("organisation", organisation));
return View(typeReportSource);
}
}
And here is the report design that i've created...
public partial class OrganisationSample : Telerik.Reporting.Report
{
private IOrganisationLogic _organisationLogic;
public OrganisationSample(bool flag, OrganisationLogic organisation)
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
if (flag)
{
this.DataSource = organisation;
}
}
}
what is the best approach I could do? Iwant to set the objectDataSource dynamically, each report has its own objectDataSource and I just want a single viewer that can use render multiple reports.