2013-12-21 109 views

回答

0

下面的代碼可用於使用單個報表查看器使用多個rdlc文件。

//添加該代碼嵌入在運行時// reportViewer1

reportViewer1.Reset(); 
    reportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewer.Report2.rdlc"; 
    this.reportViewer1.RefreshReport(); 

報告 - >報告查看器控制

//的ReportViewer - >名稱的解決方案

//Report2.rdlc - >報告名稱

+0

請記住,我有不同的參數爲每個reports.so這不適用於這種情況。 – Sandip

0

您可以在運行時設置ReportViewer控件的每個方面。

要設置正確的RDLC文件:

YourReportViewerControl.LocalReport.ReportPath = <path to your rdlc file> 

在運行時添加參數:

YourReportViewerControl.LocalReport.DataSources.Add(New ReportDataSource("yourDataSourceName", YourDataSource)) 

所以你只能在設置:

Dim parA As New ReportParameter("parA", "this is A") 
Dim parB As New ReportParameter("parB", "this is B") 

YourReportViewerControl.LocalReport.SetParameters(New ReportParameter() {parA, parB}) 

在運行時添加數據源發送給ReportViewer的rdlc的正確參數/數據集。

0
try this 
ReportViewer1.LocalReport.ReportPath = @"Your\report\path.rdlc"; 
      ReportViewer1.LocalReport.DataSources[x] = "datasourceID"; 
      ReportViewer1.LocalReport.Refresh(); 
in Asp.net 

for windows form 

ReportViewer1.LocalReport.ReportPath = @"Your\report\path.rdlc"; 
      ReportViewer1.LocalReport.DataSources[x] = "datasourceID"; 
      ReportViewer1.RefreshReport();