Asp.Net - SQL Reporting Srevice error "Failed to load viewstate" when "drill through"

Dear all,

i have developed a test page with master page and report viewer control,and 3 reports, with .Net Framework 2.0, visual studio 2005 and SQL Server 2005.

The report viewer i use will show a report, with drill through to show a second report, and then from the second report to the third.

The problem is whenever i try to navigate from second report to show the third report using drill through (using Navigation , Jump To Report), i keep on getting the following error which is "Failed to load viewstate".

Further more, whenever i navigate from first report to second report, and click on the "next page button" as the second report contains 2 pages, it will bring me back to first report.

When i attempt to navigate to second report again, it gaves me the same error as my first problem as below.

"Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

" [HttpException (0x80004005): Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.]

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +353

System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300

System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300

System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300

System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300

System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300

System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300

System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142

System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300

System.Web.UI.Page.LoadAllState() +520

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3444

 

Any help is appreciated. Regards, Cedric

0
jovovick
8/6/2007 8:46:59 AM
asp.net.ssrs 4514 articles. 1 followers. Follow

5 Replies
1021 Views

Similar Articles

[PageSpeed] 53

HI,

You can try to set the PlaceHolder that you are dynamically adding the control to EnableViewState="False".


Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
0
Rex
8/8/2007 6:06:34 AM
Hi Rex, 

Appreciate your reply. By setting the EnableViewState = False will cause the report fail to load with an error message stating that ViewState must be enabled.
0
jovovick
8/8/2007 1:27:23 PM

 I'm having the same problem. I have a ReportViewer added to a page, and when I drillthrough it works the first time, but not the second (I get the viewstate-exception you got).

 I am using the RV in remote, asynchronous mode. It is declared in the ascx (this is a control), and the report is loaded on the first page_load (based on parameters, path, serverurl, etc. from a database).

 
So far I've come to the following conclusions:

  • Disabling viewstate does not work - it makes the ReportViewer not work
  • Navigating through the pages on the first report is done asynchronously
  • When I drill through a postback is done
  • The next postback fails (does not matter what it is)
  • The drillthrough is apparently being stored in the ReportViewer's viewstate, but as the ReportViewer is not set up to any ServerReport on the second postback (nor the first, but that does not cause a problem) it apparently cannot load the viewstate.

I've tried just creating a new project with only the reportviewer in one page all alone, and linkind it declaratively to a report with drillthrough. I get the same error.

 Is this a bug in the Microsoft.Reporting.Webforms.ReportViewer?
 

 


"Violence is the last refuge of the incompetent."
-Isaac Asimov

http://personalinertia.blogspot.com
0
TomasEkeli
8/22/2007 1:27:44 PM

 Here are the files from the simple project using just one page.

The web.config is set up to load the ReportViewer

  

<configuration>
	<appSettings/>
	<connectionStrings/>
	<system.web>
		<compilation debug="true" strict="false" explicit="true">
			<assemblies>
				<add assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
				<add assembly="Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
			</assemblies>
		</compilation>
		<pages>
			<namespaces>
				<clear/>
				<add namespace="System"/>
				<add namespace="System.Collections"/>
				<add namespace="System.Collections.Specialized"/>
				<add namespace="System.Configuration"/>
				<add namespace="System.Text"/>
				<add namespace="System.Text.RegularExpressions"/>
				<add namespace="System.Web"/>
				<add namespace="System.Web.Caching"/>
				<add namespace="System.Web.SessionState"/>
				<add namespace="System.Web.Security"/>
				<add namespace="System.Web.Profile"/>
				<add namespace="System.Web.UI"/>
				<add namespace="System.Web.UI.WebControls"/>
				<add namespace="System.Web.UI.WebControls.WebParts"/>
				<add namespace="System.Web.UI.HtmlControls"/>
			</namespaces>
		</pages>
		<authentication mode="Windows"/>
		<httpHandlers>
			<add verb="*" path="Reserved.ReportViewerWebControl.axd" type ="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
		</httpHandlers>
	</system.web>
</configuration>

 The Page contains the ReportViewer - declaratively linked to a Report which is part of the AdventureWorks BI examples (chosen because it has drillthrough) - just replace "utv18" with your own servername to test

  

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Tests._Default" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
	Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
		<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
			Height="800px" ProcessingMode="Remote" Width="800px">
			<ServerReport ReportPath="/AdventureWorks Sample Reports/Product Line Sales" ReportServerUrl="http://utv18/reportserver" />
		</rsweb:ReportViewer>
		<br />
    </div>
    </form>
</body>
</html>
  1.  Load the page - click through to something (The Employee names are available)
  2. This loads the correct report (Employee sales summary)
  3. Clickthrough to any of the Sales Orders (should send you to the next report)
  4. Observe beautiful error

Server Error in '/' Application.

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.]
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +353
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300
   System.Web.UI.Page.LoadAllState() +520
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3444


Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833

 


"Violence is the last refuge of the incompetent."
-Isaac Asimov

http://personalinertia.blogspot.com
0
TomasEkeli
8/22/2007 1:40:02 PM
Hi TomasEkeli, do you have vs2005 service pack 1 installed ? i found out that after i remove my installation of vs2005 with service pack , the problem goes away. Hope this helps
0
jovovick
8/23/2007 2:54:57 AM
Reply:

Web resources about - Asp.Net - SQL Reporting Srevice error "Failed to load viewstate" when "drill through" - asp.net.ssrs

Resources last updated: 1/3/2016 9:30:14 AM