使用 VS 2008.
Using VS 2008.
我有两个存储过程,一个用于获取主报告的数据,另一个用于获取子报告的数据,并且两个 SP 都使用相同的参数 QuoteID.
I have two stored procedures, one used to get data for the main report and other for Sub report and both the SP's use the same parameter QuoteID.
我已使用 ReportDocument 向主报告发送参数.但我不知道如何向 SubReport 发送参数.
I have send parameter to main report using ReportDocument. But I am not aware how to send parameters to SubReport.
我使用报告文档的 setparameter 方法尝试了许多不同的方法,该方法也将子报告名称作为参数.但它没有.
I tried many diff ways using the reportdocument's setparameter method which also takes subreport name as argument.But it didn't.
下面是我用过的代码
string Type = gvQuotationDetails.Rows[QuoteIndex].Cells["Type"].EditedFormattedValue.ToString();
FilePath = ConfigurationManager.AppSettings["EMP_IMG_PATH"].ToString() + "\" + ValQuoteID.ToString() + ".pdf";
DeleteExistingFile(FilePath);
try
{
AccountsPayableMaster objAPM = new AccountsPayableMaster();
QuotationReport obj = new QuotationReport();
objReportDocument.Load(Application.StartupPath + @"
ptQuotationReport.rpt");
obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_SalesOrderReport;1");
obj.crysQuotationReport.LogOnInfo = objAPM.ConnectionDetails("SD_GetBatchReportDetails;1");
obj.crysQuotationReport.ReportSource = objReportDocument;
objReportDocument.SetParameterValue("@QuoteID", ValQuoteID);
objReportDocument.SetParameterValue("Type", Type);
//objReportDocument.Subreports[Application.StartupPath + @"BatchSubReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
//objReportDocument.Subreports["BatchReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
string[] Print = objAPM.GetPrintDetails();
SetPrintParameters(objReportDocument, Print);
obj.Show();
objReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, FilePath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
向子报表发送参数
//objReportDocument.Subreports[Application.StartupPath + @"BatchSubReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
//objReportDocument.Subreports["BatchReport.rpt"].SetParameterValue("@QuoteID", ValQuoteID);
////objReportDocument.SetParameterValue("@QuoteID", ValQuoteID,"BatchReport.rpt);
没有任何效果.我已经为此浪费了两天时间.[SD_SalesOrderReport;1]
主 SP 和 [SD_GetBatchReportDetails;1]
子报表 SP.
nothing worked.I have already wasted two days on this. [SD_SalesOrderReport;1]
main SP and [SD_GetBatchReportDetails;1]
subreport SP.
如果有人可以为此提供解决方案,那就太好了.如果设计中有一些更改,请分享图片.谢谢.
It would be great if someone can provide a solution for this.If there are some changes to be made in designed please share images.Thank you.
经过多次尝试,我终于解决了.也许这对其他人有帮助.我在Main和SubReport中使用了相同的参数Name,使用下面的代码来设置它的参数
Finally after lot of trails, I have solved it.May be this will be helpful to others.I have used the same parameter Name for Main and SubReport, used below code to set its parameter
objReportDocument.SetParameterValue("@QuoteID", ValQuoteID,objReportDocument.Subreports[0].Name.ToString());
这篇关于如何在水晶报表中向子报表发送参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!