I have a class which uses a list for passing to ssrs and for each report I had to define a list of that type. like this
List<ReportClass1> ReportClass1prods;
public List<ReportClass1> GetReportClass1
{
get
{
return ReportClass1prods;
}
}
List<ReportClass2> ReportClass2prods;
public List<ReportClass2> GetReportClass2
{
get
{
return ReportClass2prods;
}
}
List<ReportClass3> ReportClass3prods;
public List<ReportClass3> GetReportClass3
{
get
{
return ReportClass3prods;
}
}
and then each one has its own function
public void LoadReport1(List<ReportClass1> products)
{
ReportClass1prods = products;
reportViewer1.Clear();
reportViewer1.Reset();
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
reportViewer1.LocalReport.DataSources.Add(
new ReportDataSource("ReportClass1", GetReportClass1));
reportViewer1.RefreshReport();
}
Is there anyway/ what is the best way to make it so I dont need to copy and paste each list function for each new report but can dynamically figure out the type so there is only 1 list and 1 load function?