在运行时将参数传递给mvc中的rdlc文件

Passing parameters to rdlc file in mvc at runtime

我在 visual studio 中创建了很多 rdlc 报告。我让它们导出为 excel、pdf、图像和 word。现在我需要设置参数,以便在运行时,用户可以为某个字段定义开始日期和结束日期。该字段是 PSURcvd。我已将参数 StartDate 和 EndDate 添加到 rdlc "HolbrookReceived"。但我不知道如何将它们分配给 PSURcvd 字段以及如何在运行时提示文本框输入日期。我该怎么做?

这是我控制器中的代码。

 public ActionResult HolbrookReceivedReport(string id)
    {
        LocalReport lr = new LocalReport();
        string path = Path.Combine(Server.MapPath("~/Report"), "HolbrookReceived.rdlc");
        if (System.IO.File.Exists(path))
        {
            lr.ReportPath = path;
        }
        else
        {
            return View("Index");
        }
        List<TblPSU> cm = new List<TblPSU>();
        using (PSU_DatabaseSQLEntities dc = new PSU_DatabaseSQLEntities())
        {
            cm = dc.TblPSUs.ToList();
        }
        ReportDataSource rd = new ReportDataSource("HolbrookReceivedDataSet", cm);
        lr.DataSources.Add(rd);
        string reportType = id;
        string mimeType;
        string encoding;
        string fileNameExtension;



        string deviceInfo =

        "<DeviceInfo>" +
        "  <OutputFormat>" + id + "</OutputFormat>" +
        "  <PageWidth>8.5in</PageWidth>" +
        "  <PageHeight>11in</PageHeight>" +
        "  <MarginTop>0.5in</MarginTop>" +
        "  <MarginLeft>1in</MarginLeft>" +
        "  <MarginRight>1in</MarginRight>" +
        "  <MarginBottom>0.5in</MarginBottom>" +
        "</DeviceInfo>";

        Warning[] warnings;
        string[] streams;
        byte[] renderedBytes;

        renderedBytes = lr.Render(
            reportType,
            deviceInfo,
            out mimeType,
            out encoding,
            out fileNameExtension,
            out streams,
            out warnings);

        return File(renderedBytes, mimeType);


    }

这是我的看法

<ul class="nav nav-pills nav-stacked">
    <li>
        <div class="btn-group">
            <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                Ramona Holbrook Received <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
                <li><a href="@Url.Action("HolbrookReceivedReport", new { id = "PDF" })">PDF</a></li>
                <li><a href="@Url.Action("HolbrookReceivedReport", new { id = "Excel" })">Excel</a></li>
                <li><a href="@Url.Action("HolbrookReceivedReport", new { id = "Word" })">Word</a></li>
                <li><a href="@Url.Action("HolbrookReceivedReport", new { id = "Image" })">Image</a></li>
            </ul>
        </div>
    </li>

看看下面的内容,看看是否对您有所帮助。 How to pass textbox/Combobox value to rdlc report text field?https://www.youtube.com/watch?v=859BmmVOm8M