I’ve a ReportViewer(.rdlc) in my app. I want to show a datatable, which is generated dynamically from codebehind, in Reportviewer in Table object.
How to do this? dataset has to be sent to report through codebehind.
I Have My Code Behind file
DataTable dt = Session["ReportOnUser"] as DataTable;
if (dt.Rows.Count > 0)
{
ReportDataSource rds = new ReportDataSource("ReportOnUser", dt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
aspx file:
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="800px">
<LocalReport ReportPath="ReportsReport1.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ReportOnUser" Name="ReportOnUser" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
I have adde an rdlc file with No design or xsd file Report1.rdlc.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The Code above is working perfectly. the only issue was ‘Microsoft.ReportViewer.WebForms’ dll added was of different version.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0