Can I create a RDLC and databind a table at run time without creating dataset in design time?
Just wondering if it's possible to databind a RDLC's table at run time.
I've crea开发者_如何学Pythonted 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?
You need a Dummy Data Set for the report. You can fill it with you load data on runtime.
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.
精彩评论