In the "Simple implementation of Crystal Report Dynamic Load", the methods provided are sometimes not working very well. Thus, through the continuous experiment and data query, a better method is finally discovered. The core code is as follows
Crystaldecisions.Web.crystalReportViewer CrystalReportViewer1; string path = server.mappath ("./"); path = path @ "/ report / report.rpt"; path = path.replace ("//", ""); ReportDocument Rep = new reportDocument (); rep.load (path); DataSet DS = getDataSet (getConn ()); rep.SetDataSource (DS); CrystalReportViewer1.Reportsource = rep; crystalreportViewer1.DATABIND ();
As shown above, this method uses the ReportDocument class LOAD () method to load the report template into the memory, and push the DataSet data into the template using the push mode. Finally, this ReportDocument is bound to CrystalReportViewer.