Persistence limitations when report binding in the Page_Load event handler

Parent Previous Next

 

Report Application Server .NET SDK Developer Guide

Persistence limitations when report binding in the Page_Load event handler

See Also 

 







In ASP.NET Web applications it is common practice to place all startup code for the page in the Page_Load event handler, which is called by the Page.Load event.

In particular, control data binding code is usually stored within the Page_Load event handler. However, placing the binding code in this event handler causes a problem with ViewState. The problem and typical resolution is as follows:

This resolution makes one crucial assumption: that both the data and mouse click events can be serialized to ViewState. However, the CrystalReportViewer control binds to objects that are non-serializable (specifically, the ReportDocument class, the ReportClientDocument class or the InfoObject class.)

Since only the CrystalReportViewer control's mouse click events can be serialized to ViewState, binding to a non-serializable report class creates an irresolvable problem during page reloads:

NoteNote

This approach is typically observed when clicking through a multiple-page report in the CrystalReportViewer control. The report mysteriously keeps returning to page 1.

Recommended solution: move the CrystalReportViewer control's binding code to the Init event

The solution for the CrystalReportViewer control is to move your report binding code to the Init event, which occurs before ViewState is restored.

This solution raises one complication. Since the Init event is coded against less commonly than the Load event, it is harder to access. In Visual Studio .NET 2003 Web or Windows projects, the Init event handling code is located within the Web Form Designer Generated code region, an area that is typically hidden and reserved for generated code.

To resolve this, the following approach is recommended:

See Also

© 2021 SAP AG. All rights reserved.

http://www.sap.com/sapbusinessobjects/

Support services

http://service.sap.com/bosap-support/

Created with the Personal Edition of HelpNDoc: Easily create EBooks