DataTable reportData = this.GetReportData(startId, endId, empId, minAmount, reportType);
ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportEmbeddedResource = "PDCL.ERP.Modules.Marketing.Reports.rptDoctorDetail.rdlc";
ReportDataSource ds = new ReportDataSource();
ds.Name = "DoctorDetail_Report";
ds.Value = reportData;
reportViewer.LocalReport.DataSources.Add(ds);
reportViewer.RefreshReport();
this.WindowsFrmHost.Child = reportViewer;
this is my code.I'm using SSRS but the viewer only shows but not any data. Why..?
I think you need to call refresh report after the reportviewer is loaded into the view.
Here is my code which works (reportViewerHost is WindowsFormsHost, declared in UserControl using XAML)
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
SqlReportViewModel report = (SqlReportViewModel)this.DataContext;
Microsoft.Reporting.WinForms.ReportViewer reportviewer = new Microsoft.Reporting.WinForms.ReportViewer();
reportViewerHost.Child = reportviewer;
reportviewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
reportviewer.LocalReport.ReportPath = report.FileName;
report.LoadReport(reportviewer.LocalReport);
reportviewer.RefreshReport();
}
in the LoadReport Method of the SqlReportViewModel, I am setting the datasource as
_report.DataSources.Add(new ReportDataSource(dataset.Name, tbl));
where _report is the reference to LocalReport object passed as an argument
LocalReport _report;
It took me a while to figure this out... hope this helps.. Good Luck..:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With