I just upgraded to the beta 2 of Crystal Reports for Visual Studio 2010 and I\'m not able to print, export, zoom, or change pages while using the web control in an ASP.NET MVC a
Crystal Report's Report Viewer control is a server side control, as such, it doesn't function properly when part of an MVC view page. Hence, when I tried to print or export, causing a post back, I would continually see a page refresh, instead of printing or exporting.
This behavior is different from ASP.NET MVC version 1 that I used with Visual Studio 2008 and the version of Crystal Reports that came with VS2008. In VS2010 and, as of now beta of, Crystal Reports 2010, the Report Viewer control needs to be on a plain old aspx page and not part of an MVC view page.
To accomplish this I took the following steps, many of these steps are the sames ones I used before in a related question, but I have tweaked them for the new behavior seen in VS2010 and CrystalReports 2010: StackOverflow.com: CrystalReportViewer Buttons Broken using MVC Framework
List<JobSummaryBody> body = model.GetJobSummaryBody(jobId, startDate, endDate);
JobSummaryByDate summary = new JobSummaryByDate();
Note: JobSummaryByDate is a data type created by Crystal Reports when I design my report, it is code generated. Think of it as all of the data that your designed report is going to need.
summary.SetDataSource(body);
Session["ReportData"] = summary;
Response.Redirect("~/CrystalReports/JobSummaryByDateView.aspx");
Note: I have created a new top level folder in my project called "CrystalReports", the folder can actually be navigated to by URL.
The source page for JobSummaryByDateView.asp is very striaght forward, add the Crystal Report Viewer, in this case I gave it an ID of Report Viewer:
<CR:CrystalReportViewer ID="ReportViewer" runat="server" AutoDataBind="true"
EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False"
ToolPanelView="None" HasDrilldownTabs="False" HasDrillUpButton="False"
HasSearchButton="False" HasToggleGroupTreeButton="False"
HasToggleParameterPanelButton="False" ReuseParameterValuesOnRefresh="True" />
protected void Page_Init(object sender, EventArgs e)
{
ReportViewer.ReportSource = Session["ReportData"];
}