Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
hi,
i am using report viewer for the first time, i need to pass a data table to report.rdlc which is been created at runtime.
Note: data table columns are not fixed. it changes with respect to user selection.

i am able to add columns into data set using code, but i am not able to pass it to table in Report i.e. drag colummns into tablix of report.rdlc for displayig purpose.

Requirement: i only need to display table into report which is dynamic i.e. number of rows and columns is decided at runtime by user.

kindly guide me way out.

TIA.
Regards,
Sushant

What I have tried:

DataCheck dc = new DataCheck(); //object of data set is created
dc.DataTable1.Columns.Add("time_stamp"); //adding columns dynamically @ runtime into table in dataset

ReportDataSource rds = new ReportDataSource("DataSet1", dt);//dt is data table, dataset1 is name of dataset
Posted
Updated 6-Feb-19 21:37pm
v2

As is stated here[^] and here[^] there's no simple way to create dynamic columns in RDLC report at runtime, becuase an RDLC file is bit complicated XML file. Seems the only way to achieve that is to change to RDL. For further details, please see: Report Definition Language (SSRS) - SQL Server Reporting Services (SSRS) | Microsoft Docs[^].

Do not forget to follow the links i provided.

Good luck!
 
Share this answer
 
Comments
Member 12694392 5-Feb-19 4:03am    
thanks for the reply. i have been through the links, but since i am new into this i am not able to understand. an runtime exmaple would be very helpful.
thanks
Maciej Los 5-Feb-19 4:11am    
So, follow the links under [here] words.
hi,
i solved the query,
what i did was as follows

i copied the text from rdlc i.e. xml file into text file via code,
added tablix and data set part of code through c# in to text file.
after the modification was ready, replaced the whole text from XML to text file data.

result i achived was, dynamic data set creation, dynamic table creation in report viewer.

thanks for the support
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900