Data | Crystal Report | show | Crystal Report
Crystal Report 10 version, no longer on the Crystal Report 9 as automatically help you to the subreport set Recordset, you need to add yourself in the program
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
DataSet Newds = new DataSet ();
。
。 Get the data set of the report set to Newsds
DataSet dstmain=biz. Getdatasetlist (Pstart, Pend, pstorename);
NEWSDS.TABLES.ADD (Dstmain.tables[0]. Copy ());//Add the main report dataset
DataSet dstPOS1 = new DataSet ();
DataSet dstPOS2 = new DataSet ();
DstPOS1 = biz. Getdatasetlist (Pstart, Pend, pStoreName1);
DstPOS2 = biz. Getdatasetlist (Pstart, Pend, pStoreName2);
NEWSDS.TABLES.ADD (Dstpos1.tables[0]. Copy ());//Add Child report DataSet
NEWSDS.TABLES.ADD (Dstpos2.tables[0]. Copy ());//Add Child report DataSet
。
Type M_report_type = M_assembly.gettype (reportclassname);//reportclassname is the report name
Object AA = M_assembly.createinstance (m_report_type. FullName);
ReportClass reportengine = (reportclass) m_assembly.createinstance (M_report_type. FullName);
for (int i=1;i<newds.tables.count;i++)//To assign a value to a subreport
{
Reportdocument Osubreport=reportengine.subreports[i-1];
Osubreport.setdatasource (Newds);
}
Reportengine.setdatasource (Newds);
Crystalreportviewer1.reportsource = Reportengine;
Return