【问题标题】:Showing RDLC report inside asp.net mvc 5 application在 asp.net mvc 5 应用程序中显示 RDLC 报告
【发布时间】:2015-09-18 07:41:49
【问题描述】:

我创建了以下视图表单来过滤结果,

我还创建了以下 aspx 网络表单来生成报告

现在我想在视图表单中单击 生成报告 按钮(第一张图片)我应该能够将参数传递给文本框

  1. 键入
  2. 类别
  3. 子公司
  4. 国家
  5. 日期

以网络形式生成结果并显示 Microsoft 报告向导 (RDLC),如第二张图像。

我已经分别做了这些事情,我想把它们联系在一起

【问题讨论】:

  • 我在这里真的没有看到问题......第一个屏幕截图上的视图表单有效吗?例如,您可以从过滤器中传递变量并填写下面的表格吗?那么你应该没有问题将它们作为参数传递给你的记者。也许this walktrough 可能对你有用。

标签: asp.net-mvc webforms reporting rdlc microsoft-reporting


【解决方案1】:

1

使用过滤器属性创建模型,但在 report.rdlc 中为数据集添加数据表,例如

public class paramsModel
{
    public string typeRep {get; set;}
    public DateTime dateRep {get; set;}
    public DataTable dataReport {get; set;}
}

2

在您的控制器中为视图创建 ActionResult

    public ActionResult showReport()
    {
        return View();
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult showReport(paramsModel paramsRep)
    {
        if (ModelState.IsValid)
        {
            paramsRep.dataReport = LocalData.GetDataFromDb(paramsRep.typeRep, paramsRep.dateRep);               
        }

        return View(paramsRep);
    }

3

在你看来

@model yourproyect.models.paramsModel
@{
    ViewBag.Title = "Report page";
    var settings = new ControlSettings
    {
        UseCurrentAppDomainPermissionSet = true,
        EnableHyperlinks=true
    };
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()    
    <div class="form-horizontal">
        <h4>Report filters</h4>
        <hr />
        @Html.ValidationSummary(true)

        <div class="form-group">
            @Html.LabelFor(model => model.typeRep , new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.typeRep , ModelMetadata.FromLambdaExpression(model => model.typeRep , ViewData).EditFormatString, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.typeRep )
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.dateRep , new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.dateRep , ModelMetadata.FromLambdaExpression(model => model.dateRep , ViewData).EditFormatString, new { @class = "form-control datepicker" })
                @Html.ValidationMessageFor(model => model.dateRep )
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </div>
    </div>  

}

<div>
    @if (Model != null)
    {
        <div >
         @Html.MvcReportViewer("Reports/YourReport.rdlc").ProcessingMode(ProcessingMode.Local).LocalDataSource("DataSet1", Model.dataReport).ControlSettings(settings).Attributes(new { Style = "width:100%; border:none; height: 87vh;" }).Method(FormMethod.Post)
        </div>
    }       
</div> 

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")

    <script type="text/javascript">
        $('.datepicker').datepicker({
            dateformat: "@System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToLower()",
            language: "es",
            autoclose: true,
            showAnim: 'blind',
            highlightWeek: true
        }); //Initialise any date pickers
    </script>
}

【讨论】:

  • 可能在我尝试过但失败后发布完整的详细信息
猜你喜欢
  • 2012-01-24
  • 2015-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-16
  • 1970-01-01
  • 1970-01-01
  • 2020-01-13
相关资源
最近更新 更多