1、说明
在aspx页面中点击按钮,在reportview中显示报表,但是点击按钮后没有反应
2、解决
(1)不要讲reportview和具体的报表在设计时建立绑定关系
(2)在page_load事件中添加如下代码
if (!IsPostBack & !IsCallback) Session["Value"] = null; if (Session["Value"] != null) ReportViewer1.Report = new ReportLibrary.BasicXtraReport();
(3)绑定数据
Session["Value"] = Guid.NewGuid(); ReportViewer1.Report = new ReportLibrary.BasicXtraReport(); ReportViewer1.DataBind();
(4)绑定reportview的从内存中读取数据的事件
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); }