c# - Microsoft 报告参数未重置

标签 c# asp.net report rdlc microsoft-reporting

我有一些使用 Microsoft Reporting rdlc 文件设计的非常定制的报告。在第一份报告中,我使用了 43 参数:

R_1_1,R_1_2,R_1_3,R_1_4,R_1_5,R_1_6,R_2_1,R_2_2,...

在第二份报告中,我有 78 个参数,所以:

R_1_1,R_1_2,R_1_3,R_1_4,R_1_5,R_1_6,R_1_7,R_1_8,R_2_1,R_2_2,...

我将此代码用于绑定(bind)报告:

this.ReportViewer.LocalReport.ReportPath = BaseAddress + drpReportNumber.SelectedValue.Trim() + ".rdlc";
    this.ReportViewer.LocalReport.Refresh();

    this.ReportViewer.LocalReport.DataSources.Clear();
    Microsoft.Reporting.WebForms.ReportDataSource rprtDTSource = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", new DataTable("DataSet1"));
    this.ReportViewer.LocalReport.DataSources.Add(rprtDTSource);
    this.ReportViewer.LocalReport.Refresh();

    if (parameters != null && parameters.Count > 0)
    {
        for (int i = 0; i < parameters.Count; i++)
        {
            ReportParameter p = new ReportParameter(parameters[i].ParameterName, parameters[i].ParameterValue);
            this.ReportViewer.LocalReport.SetParameters(p);
        }
    }

问题是当我创建第一个报告然后我还想创建第二个报告时,报告查看器引发此错误:

{"An attempt was made to set a report parameter 'R_1_7' that is not defined in this report."}

我有两个问题;

  1. 参数个数有限制吗?

  2. 我认为当我将 ReportViewer 绑定(bind)到第一个报告时它不包含 R_1_7,并且在第二次时参数列表不会重置并且它使用第一个参数列表。我该如何解决这个问题?

最佳答案

我刚找到 this blog post这似乎正是您的问题。

在您的 this.ReportViewer.LocalReport.DataSources.Clear(); 之前添加:

this.ReportViewer.Reset();

关于c# - Microsoft 报告参数未重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13681915/

相关文章:

c# - 重写方法声明

minOccurs ="0"元素上的 C# XSD 验证失败

asp.net - 启用自定义错误时,Elmah 不会触发

c# - 即使文件存在于我的路径中,File.Exist 条件在 asp.net 中不起作用

c# - 在 Web API 中正确使用 async/await

automation - JUnit 报告器不显示 JBehave 中每个步骤的详细报告

c# - 编译 eAccelerator 解码 PHP 编码文件

eclipse - 如何在 BIRT 中通过 URL 传递输入参数?

java - 如何用JAVA获取 Crystal 报表参数名称

c# - 带有文档索引作为附件的FileSystemwatcher