I am trying to add two DataTables to a Table (tablix) in my report using ReportViewer.
DataTables
- dtPrograms (Name, Description)
- dtImprovements (Improvement)
I'll have a list of programs and a list of improvements for each program.
Here's an example of what I'm looking for:
I'm not sure how to design my ReportViewer. Is using a Table (tablix) a good method or are there easier methods of doing so? Perhaps using a Matrix? How would you go about designing a report that contains two DataTables?
Detailed Solution
I manually created a DataSet (
ds
), a DataTable (dtTest
) and manually populated it with information. For example: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.