2017-02-03 64 views
0

我已經構建了一個SSRS報告,它以計數數據和成本數據的形式總結了我的數據。我顯示此數據的文本框中有一個操作設置,可使用摘要報告中傳遞的參數打開更詳細的報告。當在SSRS服務器上查看時,這些報告按照需要運行。爲什麼我出現此錯誤{「由於對象的當前狀態,操作無效」#:C#

現在我有一個Web應用程序,它使用C#來管理這些報告的數據輸入,並且我使用一個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"; 
    } 

任何人都可以提供哪些與錯去的解釋報告?

+0

哪一行導致錯誤? –

+0

這裏是一些它:在System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object o,Object t,EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,EventArgs e) at System .Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) – Perry

+0

請編輯您的問題 –

回答

0

我能解決這個問題。校正後的代碼如下:

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

我不得不檢查被每次頁面加載,看看是否被調用詳細報告,其中有一個不同的路徑返回的報告路徑。如果是這樣,那麼if塊失敗並打開鏈接的報告。

相關問題