Report Viewer - clear?

Posted by: llarose on 10 September 2017, 11:34 am EST

  • Posted 10 September 2017, 11:34 am EST

    I'm using a report viewer to dynamically create reports.   If I view report 5, it shows as expected.  However, if I go back to my search list and choose a new report, I still see report 5.  I stepped through the code, I am still setting the physical application path to the new report,b ut it shows me the previous report.  Is there a way to erase its memory of the first report?

  • Replied 10 September 2017, 11:34 am EST

    Reports are cached on the server. To flush the cache, you need to change something in the FileName/ReportName pair of properties for the new report to be rendered. E.g. you may assign a name like string.Format("report{0}", reportIndex) to the C1ReportViewer.ReportName when the selected report changes. Hope this helps.

  • Replied 10 September 2017, 11:34 am EST

    I changed the report name with an index, but the report viewer says that the report is not found in the definition file.  Here is a sample of my code.

               C1.C1Report.C1Report rep = new C1.C1Report.C1Report();

               rep.Load(Request.PhysicalApplicationPath + "ReportDef\" + report + ".xml", name);

               string dataConnection = Request.PhysicalApplicationPath + "tempReports\" + dataFile + ".xml";

               rep.DataSource.ConnectionString = dataConnection;

               this.C1ReportViewer1.Document = rep;

    The report stays the same because it is the definition file.

    The data file changes every time.

  • Replied 10 September 2017, 11:34 am EST

    You must change the C1ReportViewer.ReportName  so that it is unique for each of your data files - NOT the name of the report you specify in C1Report.Load. So, in addition to

    this.C1ReportViewer1.Document = rep;

    you must also set this.C1ReportViewer1.ReportName to a string that is unique for each data file (does not matter what that is as long as you set the Document property as well).

  • Replied 10 September 2017, 11:34 am EST

    That works!  Thank you SO much!!!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels