How do I link the main report with the subreport RDLC asp.net Core
- public IActionResult PrintTwo()
- {
- var dt = new DataTable();
- var dtSub = new DataTable();
-
- DataTable[] dtArray = new DataTable[2];
-
- dtArray = GetEmployeeList();
- string mimetype = "";
- int extension = 1;
- var path = $"{this._webHostEnvironment.WebRootPath}\\Reports\\ReportRdlcTwo.rdlc";
- var pathSub = $"{this._webHostEnvironment.WebRootPath}\\Reports\\subReport.rdlc";
-
- Dictionary<string, string> parameters = new Dictionary<string, string>();
-
-
- parameters.Add("prm", "Z. Apple. An apple is just an apple. BMW. The accidental propeller. Chupa");
-
-
- LocalReport localReport = new LocalReport(path);
- LocalReport localReportSub = new LocalReport(pathSub);
-
- localReport.AddDataSource("DataSetContact", dtArray[0]);
- localReportSub.AddDataSource("DataSetSub", dtArray[1]);
-
-
-
- dt = dtArray[0];
- dtSub = dtArray[1];
- var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimetype);
-
-
- return File(result.MainStream, "application/pdf");
- }
-
- public DataTable[] GetEmployeeList()
- {
- var dt = new DataTable();
- DataTable[] dtArray = new DataTable[2];
- dtArray[0] = new DataTable("DataTable0");
- dtArray[1] = new DataTable("DataTable1");
-
- dtArray[0].Columns.Add("EmpId", typeof(Int32));
- dtArray[0].Columns.Add("EmpName");
- dtArray[0].Columns.Add("EmpDepart");
- dtArray[0].Columns.Add("EmpDesignation");
-
- dtArray[1].Columns.Add("EmpContId", typeof(Int32));
- dtArray[1].Columns.Add("EmpId", typeof(Int32));
- dtArray[1].Columns.Add("EmpContMobile");
- dtArray[1].Columns.Add("EmpContEmail");
- dtArray[1].Columns.Add("EmpContAddress");
- dtArray[1].Columns.Add("EmpContCity");
-
- DataRow row;
- DataRow rowTwo;
-
- for (int i = 0;i < 10; i++)
- {
- row = dtArray[0].NewRow();
- row["EmpId"]=i;
- row["EmpName"]= "Taha Suliman Ramadan" + i.ToString();
- row["EmpDepart"]= "Accounting DeprtMemt" + i.ToString();
- row["EmpDesignation"]= "SoftWare Engineer" + i.ToString();
- dtArray[0].Rows.Add(row);
-
- for (int j = 0; j < 5; j++)
- {
- int x = i * 5 + j;
- rowTwo = dtArray[1].NewRow();
- rowTwo["EmpContId"] = x;
- rowTwo["EmpId"] = i;
- rowTwo["EmpContMobile"] = "00971523215230";
- rowTwo["EmpContEmail"] = "[email protected]" + j.ToString();
- rowTwo["EmpContAddress"] = "Sharjah Gasimiya Mahata" + j.ToString();
- rowTwo["EmpContCity"] = "United Emarate Sharjah" + j.ToString();
- dtArray[1].Rows.Add(rowTwo);
- }
-
- }
- return dtArray;
- }