Model view controller 在运行时将参数传递到mvc中的rdlc文件

Model view controller 在运行时将参数传递到mvc中的rdlc文件,model-view-controller,parameters,report,rdlc,Model View Controller,Parameters,Report,Rdlc,我在VisualStudio中创建了很多rdlc报告。我让他们导出到excel、pdf、图像和word。现在我需要设置参数,以便在运行时,用户可以定义某个字段的开始日期和结束日期。该字段是PSURcvd。我在rdlc“HolbrookReceived”中添加了参数StartDate和EndDate。但我不知道如何将它们分配到PSURcvd字段,以及如何在运行时提示文本框输入日期。我该怎么做 这是我的控制器中的代码 public ActionResult HolbrookReceivedRepo

我在VisualStudio中创建了很多rdlc报告。我让他们导出到excel、pdf、图像和word。现在我需要设置参数,以便在运行时,用户可以定义某个字段的开始日期和结束日期。该字段是PSURcvd。我在rdlc“HolbrookReceived”中添加了参数StartDate和EndDate。但我不知道如何将它们分配到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);


    }
公共操作结果HolbrookReceivedReport(字符串id)
{
LocalReport lr=新的LocalReport();
字符串path=path.Combine(Server.MapPath(“~/Report”),“HolbrookReceived.rdlc”);
if(System.IO.File.Exists(path))
{
lr.ReportPath=path;
}
其他的
{
返回视图(“索引”);
}
列表cm=新列表();
使用(PSU_DatabaseSQLEntities dc=新PSU_DatabaseSQLEntities())
{
cm=dc.TblPSUs.ToList();
}
ReportDataSource rd=新的ReportDataSource(“HolbrookReceivedDataSet”,cm);
lr.数据源添加(rd);
字符串reportType=id;
字符串模拟类型;
字符串编码;
字符串文件名扩展名;
字符串设备信息=
"" +
“”+id+“”+
“8.5英寸”+
“11英寸”+
“0.5英寸”+
“1英寸”+
“1英寸”+
“0.5英寸”+
"";
警告[]警告;
字符串[]流;
字节[]渲染字节;
renderedBytes=lr.Render(
报告类型,
deviceInfo,
输出mimeType,
输出编码,
输出文件名扩展名,
流出的溪流,
发出警告);
返回文件(renderdbytes,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>
  • 雷蒙娜·霍尔布鲁克收到

查看以下内容,看看这是否对您有所帮助。 和

这对你有帮助吗?