I'm facing an issue when generating reports.
I should generate report dynamically using all data from database for it (source name and rdlc report that stores as xml string)
So I solved problem next way:
- Create local rdlc file with report xml string;
-
Set path to the file;
var rViewer = new ReportViewer(); rViewer.LocalReport.ReportPath = @"Path to the generated xml rdlc file"; var dataSource = new ReportDataSource("DataSourceName", data); rViewer.LocalReport.DataSources.Add(dataSource);
Could I specify in the code-behind directly Report XML String instead of generating the rdlc file and set path to it? Could you recommend a better way?
Thank You
Best Answer
Yes, You can provide it a StringReader object using LoadReportDefinition like so,
Where Report.Defintion is the String containing the XML of the Report's Definition.