Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's an example of an ActionMethod I use in one of my sites to generate a report:</p> <pre><code> public ActionResult WeeklyAisleReport(DateTime start, DateTime end) { var range = new DateRange(start, end); var records = _repository.Select(range, ""); var formattedRecords = AisleProductivityRecord.Generate(records).ToList(); var localReport = new LocalReport { ReportPath = Server.MapPath("~/Content/Reports/PTLWeeklyProductivity.rdlc") }; var pickRecords = new ReportDataSource("PickRecords",formattedRecords); localReport.DataSources.Add(pickRecords); const string ReportType = "PDF"; string mimeType; string encoding; string fileNameExtension; Warning[] warnings; string[] streams; //Render the report byte[] renderedBytes = localReport.Render( ReportType, null, //deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); Response.AddHeader("content-disposition", "attachment; filename=WeeklyAisleReport-" + start.ToString("yyyy_MM_dd") + "." + fileNameExtension); return File(renderedBytes, mimeType); } </code></pre> <p>Regarding the View, you can't use WebForms tags (, , etc..) in an MVC Application. You'll need to create a form that posts to the ActionMethod that generates the PDF.</p> <p>Your razor view file should look something like this (using my method as an example):</p> <pre><code> @using (Html.BeginForm("WeeklyAisleReport", "PTL")) { @Html.TextBox("start") @Html.TextBox("end") &lt;input type="submit" value="View Report"/&gt; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload