canlı tv izle | Efficient Crystal Reports.NET Databinding

Dave Knipper Was Here

Efficient Crystal Reports.NET Databinding

I hope this post can help others with one of the many pitfalls I’ve experienced while working with Crystal Reports.NET.

This post covers Crystal Reports.NET v11 (the version that comes with Visual Studio.NET 2008), and ASP.NET. The Crystal Report Viewer control in this post is manually databound to a strongly typed DataSet in the code behind.

An issue I ran into recently was the problem of navigating through the Crystal Report pages with the viewer's built-in paging controls. When I would land on report page 2, and then attempted to sequence forward to report page 3, the report would go to page 1. This problem was caused by improper databinding of the Crystal Report Viewer control.

I first attempted to handle the server side paging event in the Crystal Report Viewer control, but to no surprise… that event is not exposed by the control. After some further investigation, I discovered that I needed to do my report binding through the Init event of the ASP.NET page.

My report needed to accept a custom parameter, supplied by a DropDownList in the page. The problem I ran into was that I could not get the value from the DropDownList on PostBack because I could not access its ViewState. In an ASP.NET’s Init Event, ViewState is not accessible. Here’s how I solved my problem…

Instead of trying to get my report parameters from ViewState on PostBack, I used the Request object (brought back memories of the old classic ASP days). My OnInit code ended up looking like this: Not only did that solution solve that problem, but it also gave me a great method for future development for manually databinding Crystal Reports.NET viewer controls to custom parameters.