2016-03-02 87 views
0

我想在本地處理模式下使用ReportViewer打印值的表格。該表將具有固定數量的列和可變數量的行。數據將來自我的自定義類的列表。現在,當我在我的項目中創建一個空白Report並添加一個表(Tablix)來顯示數據時,它會要求我添加一個DataSet。但是我沒有要添加的數據集,因爲我想在代碼中使用自定義類的List來填充數據,所以我取消了DataSet嚮導。但是如果我離開DataSet,它會給我一個錯誤:「Tablix'Tablix1'在報告主體中,但報告沒有數據集,數據區不允許在沒有數據集的報告中。我可以使用自定義班級的列表作爲報告的數據嗎?如果是這樣,怎麼樣?對象是否可以用作本地處理的ReportViewer報告的數據?

+0

是的,這是可能的。 SO在描述這個過程時已經有了一個問題,所以我把你的問題標記爲重複。您可以在帖子頂部找到指向其他問題的鏈接。如果出於某種原因,發佈在那裏的解決方案不起作用,請隨時回來並擴展您的問題。 – Heinzi

+0

@海因茲謝謝!我在發佈前搜索和搜索,但顯然我並不像你那麼優秀。那個答案就是我一直在尋找的。 –

+0

不客氣!不要擔心你的搜索技能:找到你是否已經知道答案總是比較容易的(除非你知道這就是它的名字,否則你不能谷歌搜索「對象數據源」)。 – Heinzi

回答

1

https://msdn.microsoft.com/en-us/library/ms251784.aspx

Add a report to the project using the Report Wizard 

From the Project menu, select Add New Item. 

In the Add New Item dialog, select Report Wizard. Type a name for the report and click Add. 

This launches the Report Wizard with the Data Source Configuration Wizard. 

In the Choose a Data Source Type page, select Object and click Next. 

在選擇數據對象頁面上,展開BusinessObject的下的類層次結構,直到您在列表中看到產品。選擇產品,然後單擊完成。

You now return to the Report Wizard. Notice that the new data source object is added to your project in Solution Explorer. 

In the Dataset Properties page, in the Data source box, verify that global is selected. 

In the Available datasets box, verify that Product is selected. 

Click Next. 
+0

謝謝你的時間。你的鏈接正是我想要的。我不知道微軟稱自定義類是「業務對象」。 –

相關問題