Current filter:
                                You should refresh the page.

                                How to use a native ReportViewer caching functionality

                                0

                                The ReportViewer control has no built-in mechanism to save its state between postbacks. This example illustrates how to utilize the ReportViewer's CacheReportDocument and RestoreReportDocumentFromCache events to save a report into the Page cache, and restore it afterwards.

                                • Luigi Renzi 04.02.2013

                                  How can it be possible to translate this sample to work with ReportViewerExtension in Asp.Net MVC?
                                  How to get access to the underlying ReportViewer to wire up CacheReportDocument and RestoreReportDocumentFromCache events?

                                You must  log in  or  register  to leave comments
                                Select file
                                • Default.aspx.cs
                                • XtraReport1.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2011 vol 1.6 - v2012 vol 2.8
                                • v2009 vol 1.9 - v2011 vol 1.5
                                using System;
                                using System.IO;
                                using System.Web.UI;
                                using DevExpress.XtraReports.Web;
                                // ...
                                
                                public partial class _Default : System.Web.UI.Page {
                                    protected void Page_Load(object sender, EventArgs e) {
                                        this.ReportViewer1.Report = new XtraReport1();
                                    }
                                    protected void ReportViewer1_CacheReportDocument(object sender, CacheReportDocumentEventArgs e) {
                                        e.Key = Guid.NewGuid().ToString();
                                        Page.Session[e.Key] = e.SaveDocumentToMemoryStream();
                                    }
                                    protected void ReportViewer1_RestoreReportDocumentFromCache(object sender, RestoreReportDocumentFromCacheEventArgs e) {
                                        Stream stream = Page.Session[e.Key] as Stream;
                                        if (stream != null)
                                            e.RestoreDocumentFromStream(stream);
                                    }
                                }