I have a main report and a sub report. the main report is to display the billing report and the subreport is to display detail tarif of the billing. the both report work well stand alone. the subreport should take 3 parameter from the main report values.
they are idtarif,date_periode and water_usage. I dont know how the subreport take paramaters value from the main report. in code DetailTarifSubreportProcessingEventHandler below i have to hardcode the parameter to make the subreport work. I want the subreport
take the parameters value dynamically from the main report.
Here is the code from showreport.cs
public showreport(string sqlwhere) { sql = "call sp_water_bill('" + con + "','" + sqlwhere + "')"; runReportSub("reports/report_water_bill_print.rdlc","Data",loadDataChart(sql),"Report"); } private void runReportSub(string rdlc,string dataset,DataTable data,string title) { this.Text = title; this.ClientSize = new System.Drawing.Size(750, 750); rpt.ProcessingMode = ProcessingMode.Local; rpt.LocalReport.ReportPath = rdlc; rpt.LocalReport.DataSources.Add(new ReportDataSource(dataset,data)); rpt.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(DetailTarifSubreportProcessingEventHandler); rpt.Dock = DockStyle.Fill; this.Controls.Add(rpt); rpt.RefreshReport(); } void DetailTarifSubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e) { DataTable detailTarifData = null; //the subreport should take 3 parameter from the main report values. they are idtarif,date_periode and water_usage string sqlsub = "call sp_detail_tarif('3','2008-08-01','41')";//-->hard code to test the subreport and it work if (detailTarifData == null) detailTarifData = loadDataChart(sqlsub); e.DataSources.Add(new ReportDataSource("Data",detailTarifData)); }