3
我是新來的MS報告。我想要實現的是製作一個簡單的報告,這個報告將從DataTable
(通過編程的方式)填寫。這個想法是爲每個頁面的數據分配DataRow
的值。即報告頁1
將從DataTable.Rows[0]
獲得其TextBox
值,報告頁面2
將顯示來自DataTable.Rows[1]
等的值。頁數= DataRows
的數量。如何讓ReportViewer顯示多個頁面(例如每個DataRow一個頁面)?
我編寫了一個WinForms應用程序,從SQL得到一個DataTable
和過濾它根據用戶提供的參數,然後顯示一個報告。
然後我創建了一個名爲ComplianceFormDataSet
的空虛擬假人DataSet
,其中包含我將需要的所有字段名稱。這時我犯了一個.rdlc
,增加了一個TextBox
將它與這個表達式:
=Fields!CustomerCode.Value
這裏的數據傳遞到的ReportViewer背後的邏輯:
DataTable MainDataTable = new DataTable();
MainDataTable.Columns.Add("CustomerCode", typeof(string));
MainDataTable.Rows.Add("Blah1");
MainDataTable.Rows.Add("Blah2");
ReportDataSource MainDataSource = new ReportDataSource("ComplianceFormDataSet", MainDataTable);
MainReportViewer.LocalReport.DataSources.Clear();
MainReportViewer.LocalReport.DataSources.Add(MainDataSource);
MainReportViewer.RefreshReport();
當我建立這個得到一個頁面的報告說"Blah1"
。我如何讓它呈現兩頁:一個是"Blah1"
,另一個是"Blah2"
?謝謝。
好戲! –
哪個視覺工作室是這個,因爲這不適用vs2008 – Smith