2010-06-02 13 views
5
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; 

questo è il mio codice. Sto usando SSRS ma il visualizzatore mostra solo ma non tutti i dati. Perché ..?SSRS Segnala problema in wpf

+0

Hai provato ad aggiungere gestori di eventi a ReportError o RenderingCompleted per vedere se ulteriori informazioni provengono dal controllo del visualizzatore? –

risposta

1

Penso che sia necessario chiamare il rapporto di aggiornamento dopo che il reportviewer è stato caricato nella vista.

Ecco il mio codice che funziona (reportViewerHost è WindowsFormsHost, ha dichiarato in UserControl utilizzando 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(); 
     } 

nel metodo LoadReport del SqlReportViewModel, io pongo l'origine dati come

_report.DataSources.Add(new ReportDataSource(dataset.Name, tbl)); 

dove _report è il riferimento all'oggetto LocalReport passato come argomento

LocalReport _report; 

Mi c'è voluto un po 'per capire questo ... Spero che questo aiuti .. buona fortuna .. :)

0
ReportViewer reportViewer = new ReportViewer(); 
DataTable reportData = this.GetReportData(startId, endId, empId, minAmount, reportType); 
reportViewer.LocalReport.ReportPath = "Reports//abc.rdlc"; 
ReportDataSource ds = new ReportDataSource("DataSet1", reportData); 
//DataSet1 is the datasetname of the datasource on the rdlc report 
reportViewer.LocalReport.DataSources.Add(ds); 
reportViewer.RefreshReport(); 
Reports.TReportViewer report = new Reports.TReportViewer(); 
//TReportViewer is the window of wpf application where i set the reportviewerhost. 
report.reportViewerHost.Child = reportViewer; 

augurandovi rispondere alla tua domanda.