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<LabSubReport> result { get; set; }
- }
- public class LabSubReport
- {
- public int ref_id { get; set; }
- public String l_test { get; set; }
- public String t_value { get; set; }
- }
and this is how Have populated my model
- IList<LabReport> report=report=new List<LabReport>();
- IList<LabRequestEntity> empo =
- int count = 1;
- foreach (LabRequestEntity e in empo)
- {
- IList<LabTestNoteEntity> notes=e.test_note;
- IList<LabSubReport> sublist=new List<LabSubReport>();
-
-
- 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