Hi,
I am developing RDLC report say A.rdlc with 2 subreports B.rdlc and C.rdlc. Each report getting data from different Data sources, but when there are no rows/data found for the 2 subreports, report is generating but I am getting error message as
Data retrieval failed for the subreport, 'Subreport1', located at:Location\SubTrade.rdlc. Please check the log files for more information. I
need to compress the subreports when data not found or need to show empty space instead of Error message. My piece of code is shown below...
public void ProcessMainReport()
{
LocalReport reportContractNote = new LocalReport();
reportContractNote.SubreportProcessing += new SubreportProcessingEventHandler(prcProcessSubReport);
reportContractNote.ReportPath = ReportPath;
int DataType = 0;// 0--For displaying Address details in Parent Report, 1--Trade Details in subreport 1, 2--Cash Details in Subreport2.
ReportParameter recipientIDConsoCN = new ReportParameter(strparamRecipientIDConsoCN, RecipientID);
ReportParameter batchdateConsoCN = new ReportParameter(strparamBatchDateConsoCN, BatchDate.ToString());
ReportParameter transmittalreportIDConsoCN = new ReportParameter(strparamTransmittalReportIDConsoCN, TransmittalReportID.ToString());
ReportParameter datatypeConsoCN = new ReportParameter(strparamDataTypeConsoCN, DataType.ToString());
reportContractNote.SetParameters(new ReportParameter[] { recipientIDConsoCN, batchdateConsoCN, transmittalreportIDConsoCN, datatypeConsoCN });
DataTable dtConsolidatedContractNote = new DataTable();
dtConsolidatedContractNote = objBll.GetConsolidatedContractNoteData(RecipientID, BatchDate, TransmittalReportID, DataType);
reportContractNote.DataSources.Add(new ReportDataSource("DataSet1", dtConsolidatedContractNote));
}
private void prcProcessSubReport(object sender, SubreportProcessingEventArgs e)
{
DataTable dtSubReport = new DataTable();
try
{
switch (e.ReportPath)
{
case strSubTrade://Name of the Sub-report Trade Details
//Code to fill Data in DataTable and bind it to SubReport SubTrade(Trade Details)
dtSubReport = objBll.GetTradeDetails(RecipientIDTradeDetails, BatchDateTradeDetails, TransmittalReportIDTradeDetails, 1);
ReportDataSource rdsTradeDetails = new ReportDataSource("DataSet1", dtSubReport);
e.DataSources.Add(rdsTradeDetails);
//Code End
break;
case strSubRecDisb://Name of the Sub-Report Cash Details
//Code to fill Data in DataTable and bind it to SubReport SubRecDisb(Cash Details)
dtSubReport = objBll.GetCashDetails(RecipientIDCashDetails, BatchDateCashDetails, TransmittalReportIDCashDetails, 2);
ReportDataSource rdsCashDetails = new ReportDataSource("DataSet1", dtSubReport);
e.DataSources.Add(rdsCashDetails);
//Code End
break;
default:
break;
}
}
}