I have created this model object in C# and want to create a report with sub report and don't know how to link the 2; Here is my model
- public class LabReport
- {
- public int ref_id{get;set;}
- public String t_name { get; set; }
- public IList
result { get; set; }//this where i need subreport - }
- public class LabSubReport
- {
- public int ref_id { get; set; }//foreign key from Above model
- public String l_test { get; set; }
- public String t_value { get; set; }
- }
and this is how Have populated my model
- IList
report=report= new List(); - IList
empo =//dao to fetch data - int count = 1;
- foreach (LabRequestEntity e in empo)
- {
- IList
notes=e.test_note;//entity relation ship here - IList
sublist=new List (); - foreach(LabTestNoteEntity p in notes)
- {
- var sub=new LabSubReport()
- {
- l_test=p.test,
- t_value=p.result
- };
- sublist.Add(sub);
- }
- var rpt = new LabReport()
- {
- ref_id = "" + count,
- t_name=e.lab_test.t_name,
- result=sublist
- };
- count++;
- report.Add(rpt);
- }
And I would wish my report to look this way. Where its highlighted with blue is where i need the sub-report to be
I have tried this
- ReportDocument cryRpt = new ReportDocument();
- cryRpt.Load("C:/MainReport.rpt");
- cryRpt.DataSourceConnections.Clear();
- cryRpt.SetDataSource(report);
- cryRpt.Subreports[0].DataSourceConnections.Clear();
- cryRpt.Subreports[0].SetDataSource(report.select(x=>x.result));
and getting this error
Column 'ref_id' does not belong to table LabSubReport
Jignesh KumarPosted Dec 18, 2020, 6:48 AM