使用主报表查看器显示 RDLC 中的所有报表

use a master report viewer to show all reports in RDLC

我正在尝试制作一个报表查看器,它将在同一个查看器中显示所有报表。我曾经为每个 RDLC 创建单独的报告查看器。但这确实是一个漫长的过程。而且有点傻。

我使用 Table 适配器在 App_Code 文件夹中有数据集,我想将该数据集作为不同报告的 ReportDatasource 和用例。但我不知道该怎么做。无论我在互联网上得到什么,都是使用 SQL 命令来完成的。但是我已经在 DataSet 中准备好了连接和存储过程。我想使用那个数据集。

.NET 开发的新手,如果我不清楚,请见谅。

感谢任何形式的帮助。

你应该这样做:

DataSet ds = SomeMethodToRetrieveDataSet(); // e.g. via DataAdapter
// Set parameters, 
ReportParameter[] parameters = new ReportParameter[...];  
ReportDataSource reportDataSource = new ReportDataSource();
//match the DataSource in the RDLC
reportDataSource.Name = "ReportData"; 
reportDataSource.Value = ds.Tables[0];

// Addparameters to the collection
reportViewer1.LocalReport.SetParameters(parameters); 
reportViewer1.LocalReport.DataSources.Add(reportDataSource);
reportViewer1.DataBind();