C# 在 RDLC 中使用多个数据集

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15826772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 18:05:32  来源:igfitidea点击:

Using multiple datasets in RDLC

c#asp.netrdlc

提问by Ali Shah Ahmed

I am working on rdlc reports, and the reports work just fine. I got stuck when I added one more dataset to the rdlc file. On adding the dataset, it added a data source as well. I ran the project, and the report was no more working giving the error: A data source instance has not been supplied for the data source

Can some one please guide me on what steps to take in order to use multiple datasets. I am using Visual Studio 2012.

我正在处理 rdlc 报告,这些报告工作得很好。当我在 rdlc 文件中再添加一个数据集时,我被卡住了。在添加数据集时,它也添加了一个数据源。我运行了该项目,并且报告不再起作用,并给出错误:尚未为数据源提供数据源实例有人

可以指导我采取哪些步骤以使用多个数据集。我正在使用 Visual Studio 2012。

回答by Freelancer

Multiple Datasources are added as follows:

添加多个数据源如下:

ReportViewer1.LocalReport.DataSources.Add(rdS);
ReportViewer1.LocalReport.DataSources.Add(rdS1);

Refer this link:

参考这个链接:

http://www.c-sharpcorner.com/UploadFile/robo60/StandaloneRDLCReports11142007183516PM/StandaloneRDLCReports.aspx

http://www.c-sharpcorner.com/UploadFile/robo60/StandaloneRDLCReports11142007183516PM/StandaloneRDLCReports.aspx

All the parts are covered in this.

所有的部分都包含在这里面。

Also refer this usefull discussion:

另请参阅此有用的讨论:

http://forums.asp.net/t/1241964.aspx

http://forums.asp.net/t/1241964.aspx

回答by stoic_monk

Should be something like this--

应该是这样的——

ReportViewer.LocalReport.DataSources.Clear();
ReportViewer.LocalReport.DataSources.Add("DataSet_Name",DataTable);
ReportViewer.LocalReport.Refresh();

Important note-- the dataset name has to match the name that appears in the rdlc. To make sure you know what this is, open the rdlc in XML Editor and find out what the name of the dataset is. When you add the datasource programatically you must reference this name as it appears in the rdlc exactly.

重要说明——数据集名称必须与 rdlc 中出现的名称相匹配。要确保您知道这是什么,请在 XML 编辑器中打开 rdlc 并找出数据集的名称。当您以编程方式添加数据源时,您必须准确引用该名称,因为它出现在 rdlc 中。