Default.aspx.cs 程式碼後置using System.Collections;private ArrayList stockValues;private ReportDocument stockObjectsReport;ConfigureCrystalReports() 方法實作:string reportPath = Server.MapPath("StockObjects.rpt");stockObjectsReport = new ReportDocument();stockObjectsReport.Load(reportPath);stockObjectsReport.SetDataSource(stockValues);crystalReportViewer.ReportSource = stockObjectsReport;ReportDocument 屬 CrystalDecisions.CrystalReports.Engine 命名空間,載入報表後可透過 SDK 存取。
public void PopulateStockValuesArrayList()
{
if (Session["stockValues"] == null)
{
stockValues = new ArrayList();
stockValues.Add(new Stock("AWRK", 1200, 28.47));
stockValues.Add(new Stock("CTSO", 800, 128.69));
stockValues.Add(new Stock("LTWR", 1800, 12.95));
Session["stockValues"] = stockValues;
}
else
{
stockValues = (ArrayList)Session["stockValues"];
}
}
ConfigureCrystalReports() 首行呼叫此方法Default.aspx.cs 程式碼後置using System.Collections;private ArrayList stockValues;private ReportDocument stockObjectsReport;ConfigureCrystalReports() 方法實作:string reportPath = Server.MapPath("StockObjects.rpt");stockObjectsReport = new ReportDocument();stockObjectsReport.Load(reportPath);stockObjectsReport.SetDataSource(stockValues);crystalReportViewer.ReportSource = stockObjectsReport;ReportDocument 屬 CrystalDecisions.CrystalReports.Engine 命名空間,載入報表後可透過 SDK 存取。
public void PopulateStockValuesArrayList()
{
if (Session["stockValues"] == null)
{
stockValues = new ArrayList();
stockValues.Add(new Stock("AWRK", 1200, 28.47));
stockValues.Add(new Stock("CTSO", 800, 128.69));
stockValues.Add(new Stock("LTWR", 1800, 12.95));
Session["stockValues"] = stockValues;
}
else
{
stockValues = (ArrayList)Session["stockValues"];
}
}
ConfigureCrystalReports() 首行呼叫此方法