我想要打印基於DataGridView的數據源列表的報表。Tablix不顯示使用「自定義」IEnumerable創建數據集
我想爲此使用Rdlc報告。我創建了該報告,並在其中添加了一個名爲「DataSet」的DataSet的Tablix。
然後,在報告查看器中,我只是刪除該數據集,並添加一個與包含我想要的列表(IEnumerable
)相同的名稱的數據集。問題在於Tablix沒有顯示任何東西。我在網上查找,但找不到與之相關的任何內容。另外,如何使用ReportViewer使字段可見或不可見?
這是我的代碼(這是在Form's Load事件:
Sistema_financiero_Entities db = new Sistema_financiero_Entities();
IEnumerable<Cheque> cheques = db.Cheque.Where(x => x.id_cheque != 6).ToList();
ReportDataSource data = new ReportDataSource("DataSet", cheques);
try
{
this.rpt_Viewer.LocalReport.DataSources.Add(data);
this.rpt_Viewer.RefreshReport();
}
一些考慮:db是實體框架對象上下文檢查是列表(在這個例子中I'm只是走從數據庫數據,但我會用DataGridView的數據源列表,我這樣做只是爲了測試,如果這是工作)。rpt_Viewer是的ReportViewer。