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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
All the parts are covered in this.
Also refer this usefull discussion:
http://forums.asp.net/t/1241964.aspx
回答2:
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.