2013-12-21 91 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();