Last post Apr 30, 2018 02:46 AM by Fei Xue - MSFT
Apr 28, 2018 07:27 PM|Benzo___|LINK
I am trying to make a RDLC report.
This is my code:
public ActionResult Reports(string ReportType)
HojapaApplication_dbEntities Entities = new HojapaApplication_dbEntities();
DataSet1 DataSet1 = new DataSet1();
DataTable reservatiesTable = DataSet1.Tables["Reservaties"];
LocalReport localreport = new LocalReport();
localreport.ReportPath = Server.MapPath("~/Reports/Report_Reservatie.rdlc");
var entities_data = from c in Entities.Reservaties
localreport.DataSources.Add(new ReportDataSource("DataSet1", DataSet1.Tables["Reservaties"]));
string reportType = ReportType;
if (reportType == "PDF")
fileNameExtension = "pdf";
fileNameExtension = "jpg";
renderedByte = localreport.Render(reportType, "", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
Response.AddHeader("content-disposition", "attachment:filename + reservaties_report." + fileNameExtension);
return File(renderedByte, fileNameExtension);
I can make an PDF report, but with no data.
Can anyone tell me what i am doing wrong?
Apr 30, 2018 02:46 AM|Fei Xue - MSFT|LINK
Based on the code you were creating a report data source from the data table
Reservaties and you were also pull the data into entities_data. However, there is still no date in the data table Reservaties. You need to fill the data into this data table before you creating the report data source.
We can use IEnumerable<DataRow>.CopyToDataTable<DataRow>() method to fill the data into data table and more detail about fill data into data table, you can refer the link below:
Creating a DataTable From a Query (LINQ to DataSet)
Regards & Fei