【问题标题】:Why am I getting this error {"Operation is not valid due to the current state of the object."} C#为什么我会收到此错误 {“由于对象的当前状态,操作无效。”} C#
【发布时间】:2017-02-04 03:12:12
【问题描述】:

我已经建立了一个 SSRS 报告,它以计数数据和成本数据的形式总结了我的数据。我显示此数据的文本框有一个操作设置,可使用从摘要报告传递的参数打开更详细的报告。在 SSRS 服务器上查看时,这些报告可以正常工作。

现在我有一个使用 C# 来管理这些报告的数据输入的 Web 应用程序,并且我正在使用 aspx ReportViewer 在应用程序中显示这些报告。问题是,如果我从我的 C# Web 应用程序打开摘要报告,然后单击链接以打开详细报告,屏幕会发生变化,看起来它会打开详细报告,但它只是坐在那里并没有呈现报告。

当我在 LocalHost 上从 Visual Studios 运行应用程序时,当我尝试打开摘要报告时收到此错误消息; {“由于对象的当前状态,操作无效。”}

这是我正在使用的 C# 代码:

 protected void Page_Load(object sender, EventArgs e)
{
    //Get the report server url from web.config
    String reportServerUrl = ConfigurationManager.AppSettings.Get("ReportServerUrl");
    ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(reportServerUrl);

    String report = Request.QueryString["r"];
    if (report == "TransportTotals")
    {
        ReportViewer1.ServerReport.ReportPath = "/ExTraReports/TransportTotals";
        this.Title = "Transport Totals Report";
    }

谁能解释报告出了什么问题?

【问题讨论】:

  • 哪一行导致错误?
  • 这里有一些:在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) 在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) 在 System.Web.UI.Control.OnLoad(EventArgs e) 在 System.Web.UI.Control.LoadRecursive() 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  • 请编辑您的问题

标签: c# asp.net reporting-services


【解决方案1】:

我能够解决问题。更正后的代码如下:

String report = Request.QueryString["r"];
    if (report == "TransportTotals" && ReportViewer1.ServerReport.ReportPath != "/ExTraReports/NEWClosedTransportsByStateAndAgencyTypeAndNameDetail")
    {
        ReportViewer1.ServerReport.ReportPath = "/ExTraReports/TransportTotals";
        this.Title = "Transport Totals Report";
    }

我必须检查每次页面加载时返回的报告路径,以查看我们是否调用了具有不同路径的详细报告。如果是这样,则 if 块失败并打开链接的报告。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    相关资源
    最近更新 更多