如何从报表查看器控件将查询字符串参数传递到 ssrs 报表

问题描述 投票:0回答:2

在我的 2012 年 ASP.NET Web 表单应用程序中,对包含 ASP.NET 报表查看器控件的 ASPX 页面之一进行了编码 在其 Page_Load 事件处理程序中,如下所示,使用 ReportPath 属性调用远程 ssrs (SQL Server 2012) 报告。

我有两个问题:

问题1:如果我想通过属性ReportPath再传递一个查询字符串,例如deviceId=1234,我该怎么做?

protected void Page_Load(object sender, EventArgs e)
        {
                ....
                ReportViewer1.ServerReport.ReportPath = _myReportPart; // I want to pass more query string here like deviceId=1234. How can I do so?
                ReportViewer1.ServerReport.ReportServerUrl = new Uri(myReportServerUrl);
            }
        }

问题 2:在远程 ssrs rdl 报告上,报告如何使用/提取额外的查询字符串?

谢谢你。

asp.net reporting-services ssrs-2008 reportingservices-2005
2个回答
1
投票

要向 asp.net 中的报表添加参数,您可以执行以下操作

    ReportParameter rpt7 = new ReportParameter(**PARAMETER NAME**, **VALUE**);
    this.ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { rpt7 });

在上面的示例中,您可以将值替换为 Request.QueryString["deviceId"].ToString() 以将查询字符串值作为参数传递。

更多详情请参阅以下内容 http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/72fdf94f-2b5d-4fc3-82c4-7db887033507

对于除去额外参数的报告,您必须在 Visual Studio 中修改报告以除去新参数。这可以在“报告数据”窗口的参数部分下完成。


0
投票

reportURL = reader["ReportURL"].ToString();

                    // Append StartDate and EndDate parameters to the report URL
                    reportURL += (reportURL.Contains("?") ? "&" : "?") + "StartDate=" + startDate + "&EndDate=" + endDate;    solve this 
© www.soinside.com 2019 - 2024. All rights reserved.