在VS2012平台用reportviewer做报表,报表加载后,页面一直显示“正在加载”,调试,发现代码进入死循环,不停执行非IspostBack中的代码:
if (!IsPostBack) { if (Master != null) { //控件注册 var scriptManager = Master.FindControl("ReportSM") as ScriptManager; if (scriptManager != null) { scriptManager.RegisterAsyncPostBackControl(this.btn_submit); } if (reportViewer != null) { string filepath = HttpContext.Current.Server.MapPath("" + AppPath + "/ReportModel/" + reportInfo.RdlcName); reportViewer.LocalReport.ReportPath = filepath; ReportDataSource rds = new ReportDataSource("DataSet1", dt); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Add(rds); ReportParameter[] parameterArray = SetReportStyle(); ReportParameter p = new ReportParameter("ReportName", reportInfo.Title); parameterArray[42] = p; p = new ReportParameter("ReportTitle", reportInfo.Subtitle); parameterArray[43] = p; p = new ReportParameter("ReportLHead", "统计日期:"); parameterArray[44] = p; p = new ReportParameter("ReportMHead", ""); parameterArray[45] = p; p = new ReportParameter("ReportRHead", ""); parameterArray[46] = p; p = new ReportParameter("ReportLFoot", ""); parameterArray[47] = p; p = new ReportParameter("ReportMFoot", ""); parameterArray[48] = p; p = new ReportParameter("ReportRFoot", ""); parameterArray[49] = p; reportViewer.LocalReport.SetParameters(parameterArray); reportViewer.LocalReport.Refresh(); } } } else { var value = Request.Form["startDate"]; if (reportViewer != null) { ReportParameter p = new ReportParameter("ReportLHead", "统计日期:" + value); reportViewer.LocalReport.SetParameters(p); reportViewer.LocalReport.Refresh(); } }
求高手指点,这种问题该怎解决呢?
你把这句
reportViewer.LocalReport.Refresh();
去掉看看。
我试过的,不起作用........
你if的那些括号, 是不是错了。
那个没有错
先设置报表参数,再加载报表试试!
ReportParameter[] parameterArray = SetReportStyle(); ReportParameter p = new ReportParameter("ReportName", reportInfo.Title); parameterArray[42] = p; p = new ReportParameter("ReportTitle", reportInfo.Subtitle); parameterArray[43] = p; p = new ReportParameter("ReportLHead", "统计日期:"); parameterArray[44] = p; p = new ReportParameter("ReportMHead", ""); parameterArray[45] = p; p = new ReportParameter("ReportRHead", ""); parameterArray[46] = p; p = new ReportParameter("ReportLFoot", ""); parameterArray[47] = p; p = new ReportParameter("ReportMFoot", ""); parameterArray[48] = p; p = new ReportParameter("ReportRFoot", ""); parameterArray[49] = p; reportViewer.LocalReport.SetParameters(parameterArray);
放在
ReportDataSource rds = new ReportDataSource("DataSet1", dt); reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Add(rds);
前面试试!
http://blogs.msdn.com/b/brianhartman/archive/2010/03/21/reports-never-stop-loading-with-vs-2010.aspx
应该是这个原因,只是不知如何解决
找到了临时解决方案
怎么搞定的 我也是遇到这种情况