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 2002 or 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:
- Extract all CrystalReportViewer binding and configuration code into a private helper method named ConfigureCrystalReports().
- Within the Web Form Designer Generated code region, place only a single line of code in the Page_Init() event handler or OnInit() event raising method: a call to the ConfigureCrystalReports() helper method.