RDLC Data Error RRS feed

  • Question

  • 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);
            string reportType = ReportType;
            string mimeType;
            string encoding;
            string fileNameExtension;
            if (reportType == "PDF")
                fileNameExtension = "pdf";
                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";
    <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?


    Monday, April 23, 2018 9:27 PM

All replies

  • User347430248 posted

    Hi Benzo,

    The error says that Report_ID contains null value.

    Please try to check what value is passing for Report_ID at run time.

    If it is null then try to pass proper value for Report_ID to solve the error.

    If issue persist then let us know about that.

    We will try to provide further suggestions to solve the issue.



    Tuesday, April 24, 2018 9:15 AM