I have a address.rdlc file. In designer, I drag class AddressData fields from local assembly in datasource to the report designer.
Then I have code to get data for this report like:
public override void PopulateReportDataSources(ReportDataSourceCollection dataSources)
{
List<AddressData> addressData = AddressData.GetAddressByID(62398);
dataSources.Add(new ReportDataSource("AddressLabel", addressData));
}
LocalReport report = new LocalReport();
report.ReportPath = ReportPath; //this is correct
PopulateReportDataSources(report.DataSources); //this is also fine when checking data in debug mode, data is loaded
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
string deviceInfo = null;
renderedBytes = report.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); //error happen here
.....
The error message is A data source instance has not been supplied for the data source "AddressData". Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: A data source instance has not been supplied for the data source "AddressData".
Source Error: Line 107: Line 108: //Render the report Line 109: renderedBytes = report.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); ...
Can't figure it out. Help please.