Search code examples
asp.netdatatablereportingdatasourcerdlc

Can I assign RDLC object data source, my own data table?


I have an rdlc file that has a datasource. But I want to assign a data table to it at runtime. Can I do this in CS file?

I want to generate a datatable at runtime and want to use it in rdlc file's object datasource. Please suggest solutions.


Solution

  • You can try this

    
    var rptSource = new ReportDataSource("TableName", objDataTable);
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(rptSource);
    ReportViewer1.LocalReport.Refresh();