首页 新闻 会员 周边 捐助

asp.net reportviewer一直显示“正在加载中”

0
悬赏园豆:30 [已关闭问题] 关闭于 2015-02-04 15:01

在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();
                }
            }

求高手指点,这种问题该怎解决呢?

CaptainTina的主页 CaptainTina | 初学一级 | 园豆:3
提问于:2014-12-24 13:56
< >
分享
所有回答(4)
0

你把这句

reportViewer.LocalReport.Refresh();

去掉看看。

爱编程的大叔 | 园豆:30844 (高人七级) | 2014-12-24 14:34

我试过的,不起作用........

支持(0) 反对(0) CaptainTina | 园豆:3 (初学一级) | 2014-12-24 14:49
0

你if的那些括号,  是不是错了。 

问天何必 | 园豆:3311 (老鸟四级) | 2014-12-24 15:18

那个没有错

支持(0) 反对(0) CaptainTina | 园豆:3 (初学一级) | 2014-12-24 15:28
0

先设置报表参数,再加载报表试试!

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);

前面试试!

 

一生有你.Net | 园豆:204 (菜鸟二级) | 2014-12-24 15:37

http://blogs.msdn.com/b/brianhartman/archive/2010/03/21/reports-never-stop-loading-with-vs-2010.aspx
应该是这个原因,只是不知如何解决

支持(0) 反对(0) CaptainTina | 园豆:3 (初学一级) | 2014-12-26 11:23
0

找到了临时解决方案

CaptainTina | 园豆:3 (初学一级) | 2015-02-04 15:00

怎么搞定的 我也是遇到这种情况

支持(0) 反对(0) _York | 园豆:38 (初学一级) | 2015-09-10 08:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册