How to Add Two DataTables to a Tablix Using ReportViewer Design

寵の児 提交于 2019-12-04 14:02:24

Detailed Solution

I manually created a DataSet (ds), a DataTable (dtTest) and manually populated it with information. For example:

ds.dtTest.Rows.Add("Test1", "Description 1", "Improvement 1 for Test1")
ds.dtTest.Rows.Add("Test1", "Description 1", "Improvement 2 for Test1")
ds.dtTest.Rows.Add("Test1", "Description 1", "Improvement 3 for Test1")
ds.dtTest.Rows.Add("Test1", "Description 1", "Improvement 4 for Test1")
ds.dtTest.Rows.Add("Test2", "Description 2", "Improvement 1 for Test2")
ds.dtTest.Rows.Add("Test2", "Description 2", "Improvement 2 for Test2")
ds.dtTest.Rows.Add("Test3", "Description 3", "Improvement 1 for Test3")
ds.dtTest.Rows.Add("Test3", "Description 3", "Improvement 2 for Test3")
ds.dtTest.Rows.Add("Test3", "Description 3", "Improvement 3 for Test3")
ds.dtTest.Rows.Add("Test3", "Description 3", "Improvement 4 for Test3")
ds.dtTest.Rows.Add("Test4", "Description 4", "Improvement 1 for Test4")

1. Add the Tablix to the Report


2. Remove all but 1 column. Keep the column that will be repeated

In my case, I add the Improvement column here


3. Add Parent Group to the Improvement Column

I right click on the Improvement cell and Add Group > Parent Group (Under Row Groups)


4. Group By Name


5. Add a child group to your name column

This is where I add my description


6. Add Description

7. Remove Headers


Result

Here is the design:

Here is the final result:

In the Report Designer, Reports Items may have one and only one DataSet connected to it. So say your Tablix named "Tablix1" may only have one DataSet connected to it. However, if you have data from 2 Database Tables that you want to have displayed in one tablix, say "Tablix1" all you have to do it create a DataSet(.xsd) file, In there create a TableAdapter and use a query to join the two desired tables you want into one DataSet Object, then give the Report Designer that DataSet and connect "Tablix1" to it. This will allow for you to have (essentially) 2 DataSets for 1 Table.

The difference between Matrices and Tables are minuscule. If I'm not mistaken, matrices are for the case where you want Column & Row Headers and Tables are for the general column headers only. However, Tables & Matrices are both a "Tablix" when it comes to .rdlc reports. So there's nothing majorly different between the two, one is just simply easier to do row headers on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!