1
votes

I have around 20 DataTables and i want to print reports for each of them using RDLC reports. The thing is, i have to create a report for each of those DataTables. Is it possible to dynamically assign the columns from the DataTable to the RDLC report (so that i will be using only one rdlc report for all datatables, changing only the datasource)

1
Depends... if it is something like lookup reference tables, yes... if you query the data and generically assign the columns "AS" something, and allow for as many columns as the MOST columns would be. Can you elaborate / sample (edit existing question) with more details of these table structures you are trying to report on. – DRapp
I'm sorry but what do you mean by generically assigning the columns? The tables contain mostly string, integer, float values such as patient details, user details, medicaton details, etc. Each of their column names are different – sigs

1 Answers

0
votes

Per comment, your content is totally different. I meant such as a lookup table where you may have 10 lookup tables and all have generic "ID", "Description" columns, but for medical-based application (as it sounds), each of those are so widely different, I would not suggest a dynamically created report. Data widths of output different, formatting, etc. I would create a single report for each respective content needed.

Now, if your intent is to have one report generate data in different formats based on the content, such as all details about a specific patient, then you might look into SUBREPORTS for RDLC. The basic premise on this is that you have a primary report that has data for the top-most component. In this case, it might be the patient or the actual exam... your choice.

Then, at the details level, you ADD a SUBREPORT to the main report. Now, the subreports are actually just another RDLC report that is pulled into the main report, has its data source as would be made available from the primary report to display its contents (which it could have its own multiple rows / groups such as multiple medications listed). Or just a single row (patient information / or exam).

I do this in a variety of my reports and use DataSets to load the data. This way, one DataSet can have multiple DataTables in it as reference and each DataTable can have as may DataRows as available. The basic layout of such report might be

MainReportByPatient.rdlc
Patient name, birth, id, etc
address, phone, email, etc...
+------------
|  SubReportMeds.rdlc
|  +------------
|  |  Medication    Dose     Purpose
|  |  details...    details  details
|  |  details...    details  details
|  |  details...    details  details
|  +-------------
|  ExamHistory.rdlc
|  +------------
|  |  Exam Date     Reason     blah...
|  |  details...    details... blah..
|  |  details...    details... blah..
|  |  details...    details... blah..
|  |  ExamDetail.rdlc
|  |  +-------------
|  |  | additional nested level per exam to show details... just example
|  |  +-------------
|  |
|  +------------
|
+-------------

Is this something like you are needing for your report?