显示RDLC报告工具栏中的总页数

时间:2012-04-03 17:28:07

标签: reportviewer

我有几个使用MS ReportViewer的报告。报告显示标准的ReportViewer工具栏。在此工具栏上是一个页面导航部分,其中包含后退和前进按钮以及页数。对于我的报告,当报告首次加载时,它总是显示页面数量:

1 of 2?

问号表示尚未计算总页数,如果您导航到最后一页,则此号码将更新。但是我希望这个报告的总页数不需要用户导航到最后一页。

我环顾了RDLC属性,找不到任何设置。

4 个答案:

答案 0 :(得分:7)

您可以在页眉和页脚中添加一个文本框,并将其设置为Globals!TotalPages。这将强制ssrs引擎同时处理所有页面。您可以隐藏文本框。

希望这有帮助。

答案 1 :(得分:7)

另一种“更清洁”的方式:

问号表示显示的总页数不是实际页数,而是估算值。默认情况下,VS2010报表查看器控件会生成总页数作为估算值​​以提高性能。如果您愿意,可以使用ReportViewer.PageCountMode属性将页面计数模式更改为实际模式。

来源:http://social.msdn.microsoft.com/Forums/en-US/3070efeb-2eb1-4e16-a9d6-9ec8ecb36d94/reportviewer-page-controls-show-page-1-of-2-how-to-remove-question-mark?forum=vsreportcontrols

答案 2 :(得分:0)

有一个名为PageCountMode的属性,默认值为 - Estimate,您可以设置为Actual

答案 3 :(得分:0)

问号表示显示的总页数不是实际页数,而是估算值。默认情况下,VS2010报表查看器控件会将总页数计算为估算值,以提高性能。

因此,在将数据源添加到报告后,您可以在下面的代码中写入代码。

function create()
            {
                if (document.companyregister.cmpname.value === "")
                {
                    alert("Please Enter Company name");
                    document.companyregister.cmpname.value = "";
                    document.companyregister.cmpname.focus();
                    return false;
                }
                var company = document.companyregister.cmpname.value;
                var user = document.companyregister.user.value;
                var xmlhttp = new XMLHttpRequest();                    
                xmlhttp.onreadystatechange = function() {            
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {                    
                var res = xmlhttp.responseText;                    
                var resu = res.split("|");                    
                if(resu[0]=="lokesh"){                        
                      document.getElementById('selectdriver1').style.display = 'block';                                                
                      document.getElementById("drvr").style.display = "none";
                      document.getElementById('findprinter').disabled = false;
                }                                        
                document.getElementById('driver').innerHTML = resu[1];
                return false;
                }
            }
            xmlhttp.open("GET", "getaccount.php?", true);
            xmlhttp.send();                                        
            return true;

            document.getElementById("formsubmitting").style.display = "block";
            document.getElementById("hidesubmit").style.display = "none";
            return true;
            }

ReportViewer1是我的报告视图控件的ID。