Using Crystal Report in ASP.net MVC and creating generic report viewer
A sample VS 2010 project which will show how to use crystal report from ASP.net MVC project. This also shows how to create a generic/ common report viewer for showing crystal report.
Prerequisite: To build and run this sample, you must have VS 2010 SP1,MVC 3 and CR 13.
I've downloaded the sample code and it works!! I've an application build in Asp.Net MVC4 razor engine so i wanted to use aspx page separately to display the crystal report like in sample. I've done everything the same like in sample but it always turns up to a blank aspx page (crystalreportviewer not rendering), What I've done!
1: Redirect response to aspx page (from mvc controller)
2: Aspx page has the crystal viewer and in code behind I'm setting the datasource and reportsource.
Everything goes well in debugging (no exception at any point) but viewer won't show. Can you guess any reasons that I may be missing? Thanks
I was able to set/change the login on aspnetsimple.aspx.cs using rd.SetDatabaseLogon(). However, I tried to do the same on FromMvcController.cs using rptH.SetDatabaseLogon() and it didn't work.
Also, I tried commenting out the code you mentioned earlier, but I am still not able to print from the webforms report. Any suggestions?
Sorry for delay.
As i know using Razor view you cannot directly show crystal report using Crystal Report Viewer But you can show crystal report as a pdf format which i have shown on my sample(FromMVCController.cs).
Thanks for downloading my sample.
After running my sample you will able to find following tab
1. Using Web Forms
2. From Controller/Action
Now consider (1) Using Web From
Here I have used ASPX page to show crystal Report.
I downloaded your solution and i found two bugs.
First print button and everything else from toolbar doesn't work.
Second when i drag chart i your dynamic report, it shows me broken image on chart place.
Please tell me if you know how to resolve this?
Thanks for downloading my project and detecting bug.
I have done some mistake by making session = "". Thats why report is not loaded properly on postback.
Please disable following line of code from aspnetgeneric.cs
Session["ReportName"] = "";
Session["rptFromDate"] = "";
Session["rptToDate"] = "";
Session["rptSource"] = "";
Hope this will solve print problem.
I have to check with chart. Now i have no idea about chart. I am sorry for that.
"Second when i drag chart i your dynamic report, it shows me broken image on chart place."
Here dynamic report means?
Help us improve MSDN.
Visit our UserVoice Page to submit and vote on ideas!