Can I create a RDLC and databind a table at run time without creating dataset in design time?
-
06-07-2019 - |
Question
Just wondering if it's possible to databind a RDLC's table at run time.
I've created a report, put a table control, but VS compiler says it's necessary to set a dataset.
But I wanted to load data into this table using a dataset created in C# code, and not creating dataset and table adapter.
Is it possible?
Solution
You need a Dummy Data Set for the report. You can fill it with you load data on runtime.
OTHER TIPS
Yes it is possible. You can rebind the datatable on the ReportViewer control. You can use any datatable you want, as long as it matches up with the Tablename used in your RDLC file.
Code to do this would look something like this in VB.NET:
ReportViewer1.Reset()
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.LoadReportDefinition(ms) 'Reload your definition (RDLC)
'Bind dataTables to the report viewer control (This is the 'dataset' it is asking about)
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DATANAME", DATATABLE))
ReportViewer1.RefreshReport()
Use Dummy DataSet or You can also use XSLT for runtime report without dataset at design time.