文檔金喜正規買球>>FastReport中文文檔>>引用數據源
引用數據源
FastReport .Net是一款全功能的Windows Forms、ASP.NET和MVC報表分析解決方案,使用FastReport .NET可以創建獨立于應用程序的.NET報表,同時FastReport .Net支持中文、英語等14種語言,可以讓你的產品保證真正的國際性。
與 FastReport 表達式(在 "表達式 "部分中介紹)相反,切勿在腳本中使用方括號來引用數據源。取而代之的是使用 Report 對象的 GetColumnValue 方法,它會返回列的值:
string productName = (string)Report.GetColumnValue("Products.Name");
點擊復制
string categoryName = (string)Report.GetColumnValue("Products.Categories.CategoryName");
點擊復制
要引用數據源本身,請使用報告對象的 GetDataSource 方法:
DataSourceBase ds = Report.GetDataSource("Products");
點擊復制
有關 DataSourceBase 類的屬性和方法的幫助,可從 FastReport.Net 類參考幫助系統中獲取。通常,該對象在腳本中的使用方式如下:
// get a reference to the data source DataSourceBase ds = Report.GetDataSource("Products"); // initialize it ds.Init(); // enum all rows while (ds.HasMoreRows) { // get the data column value from the current row string productName = (string)Report.GetColumnValue("Products.Name"); // do something with it... // ... // go next data row ds.Next(); }
點擊復制