DataTable table; // results from store procedure. | |
IndicadoresDetalhado subReportDetalhado; //the sub report ReportSource. | |
SubReport subReport; //the sub report. | |
public IndicadoresBase(clsParametros pParametros) | |
{ | |
InitializeComponent(); | |
string[] centrais = pParametros.param_central.Value.ToString().Split(','); | |
for (int i = 0; i < centrais.Length; i++) | |
{ | |
pParametros.param_central.Value = centrais[i]; | |
table = clsRelatorio.RelatoriosIndicadoresGet(pParametros); | |
subReportDetalhado = new IndicadoresDetalhado(table); | |
subReport = new SubReport() | |
{ | |
Location = new PointU(new Unit(0.0, ((UnitType)(UnitType.Cm))), new Unit(20.0 * i, ((UnitType)(UnitType.Cm)))), | |
Name = "subReport", | |
ReportSource = subReportDetalhado, | |
Size = new SizeU(new Unit(28.7, ((UnitType)(UnitType.Cm))), new Unit(20.0, ((UnitType)(UnitType.Cm)))), | |
}; | |
this.detail.Items.Add(subReport); | |
} | |
ExibirParametros(pParametros); | |
} |
Hi,
I’m trying to display some master-detail data on a report. I have designed two separate reports and linking the detail report to a sub report item in the detail section of the master report. But the detail report (for any master row) is always displaying the records related to the first master row. Code I’m using is similar to below. Can you please help solving this.
Thanks and regards,
Kushan
MasterReport masterReport = new MasterReport();
DataTable masterDataSource = getMasterDataSource();
Foreach(DataRow drM in masterDataSource.Rows)
{
FormatMasterRows(drM);
DataTable detailDataSource = getDetailDataSource(drM);
If(detailDataSource.RowCount > 0)
{
DetailReport detailReport = new DetailReport();
Foreach(DataRow drD in detailDataSource.Rows)
{
FormatDetailRows(drD);
}
detailReport.DataSource = detailDataSource;
masterReport.subReportItem1.ReportSource = detailReport;
masterReport.subReportItem1.ReportSource = true;
}
Else
{
masterReport.subReportItem1.ReportSource = false;
masterReport.detailSection.Height = masterReport.detailSection.Height - masterReport.subReportItem1.Height;
}
}
masterReport.DataSource = drM;
DisplayRepotViewer(masterReport);