User-952930563 posted
Hi everyone,
I am new with ASP.net and i'm trying to make an easy application.
I want to make a RDLC report after someone made a reservation.
This is my code for convert to PDF and my ASPXPage:
public ActionResult Reports(string ReportType, int reportId)
{
LocalReport localreport = new LocalReport();
localreport.ReportPath = Server.MapPath("~/Reports/Report_Reservatie.rdlc");
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DataSet_Reservaties";
reportDataSource.Value = storeDB.Reservaties.FirstOrDefault(a => a.ReservatieId == reportId);
localreport.DataSources.Add(reportDataSource);
string reportType = ReportType;
string mimeType;
string encoding;
string fileNameExtension;
if (reportType == "PDF")
{
fileNameExtension = "pdf";
}
else
{
fileNameExtension = "jpg";
}
string[] streams;
Warning[] warnings;
byte[] renderedByte;
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);
}
}
@model int
@{
ViewBag.Title = "Checkout Complete";
}
<h2>@MyApplication.Resources.ResourceNL.CheckoutComplete</h2>
<p>@MyApplication.Resources.ResourceNL.ThankForTheOrder: @Model</p>
@Html.ActionLink("Export to PDF", "Reports", new { ReportType = "PDF",}, null)
But now i always get this error:
The parameters dictionary contains a null entry for parameter 'reportId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Reports
Can someone please help me en tell me how to solve this? Did i forgot something?
Thanks!!