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.
-
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
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);
}
}
Facebook
Twitter
Google+