报表查看器预览显示为空,但“导出”和“打印”工作正常。
我正为此而奋斗。我需要对现有的SSRS报表进行更改,尽管所有内容似乎都在发挥作用,但最终结果是空的报表,即使通过“报表查看器”正在为报表获取正确的数据。(脚注:该报告称为“ ByGroup”,但我将其更改为“ ByFields”,以确保现有报告仍然可以自行运行。这可能是某些问题的原因,但是我ve尝试小心避免这种情况。)
该项目使用在单独的.xsd文件中声明的数据表,该文件保存在网站的App_Code文件夹中。数据表调用一个存储过程,并且所有列均存在,并且Fill和GetData方法就位。使用数据表的“预览数据”选项,我们可以验证数据表是否正确,并返回正确的数据。如果相关,我们可以为此提供更多数据。
我们报告的.aspx文件具有正确的Report Viewer 14注册标签:
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
我们正在使用链接到TableAdapter定义的ObjectDataSource:
<asp:ObjectDataSource ID="EventListingByGroup_DataInstance" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="AEMSReports.dsAEMSReportsTableAdapters.AEMSReports_056_EventListingByFieldsTableAdapter">
的<SelectParameters>
元件精确地声明所有参数的喂存储过程。
ReportViewer的定义如下:
<rsweb:ReportViewer ID="rvEventListingByGroup" runat="server" Font-Names="Verdana"
Font-Size="8pt" Height="100%" Width="850px" AsyncRendering="False"
ClientIDMode="AutoID" InternalBorderColor="204, 204, 204" InternalBorderStyle="Solid"
InternalBorderWidth="1px" ToolBarItemBorderStyle="Solid" ToolBarItemBorderWidth="1px"
ToolBarItemPressedBorderColor="51, 102, 153" ToolBarItemPressedBorderStyle="Solid" ToolBarItemPressedBorderWidth="1px"
ToolBarItemPressedHoverBackColor="153, 187, 226" >
<LocalReport ReportPath="reports\Counts_Listings\EventListingByFields056.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="EventListingByGroup_DataInstance" Name="dsAEMSReports_AEMSReports_056_EventListingByFields" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
在.aspx.cs Page_Load例程中,我们有以下代码:
if (!IsPostBack)
{
// Set hidden fields on the form for the Select parameters...
tbFromDate.Text = Request.Form["txtFromDate"].Trim();
// ...clip...
rvEventListingByGroup.Attributes.Add("style", "margin-bottom: 30px;");
rvEventListingByGroup.Visible = true;
string[] path = HttpContext.Current.Request.Url.AbsolutePath.Split('/');
string reportPath = "";
int length = path.Length;
for (int i = 1; i < length - 1; i++)
{
if (path[i] == "Reports")
{
for (int j = i; j < length - 1; j++)
{
reportPath += path[j] + "/";
}
}
}
rvEventListingByGroup.LocalReport.ReportPath = reportPath + "EventListingByGroup056.rdlc";
rvEventListingByGroup.LocalReport.Refresh();
}
我已经使用SQL Server Profiler进行了验证,当报表查看器加载页面时,它正在使用正确的参数调用SQL Server以返回所有必需的数据,但该数据未在页面上呈现。我知道没有页脚,也没有任何设置可以管理页面调度,因此在我解决该问题之前,它将始终读为“ 1 of 1”,但是我期望的是一长页(在我们的测试案例中)150行原始数据的价值。
谁能提供关于我可能错过的建议?
提前非常感谢您。我们认为这将是一个简单的更改,但是由于我们的报告编写者(工作人员)离开了,因此我们迫切需要在短时间内进行这些更改,而没有必要的技能来对其进行备份...
有了来自social.msdn的链接,我找到了答案。我将SizeToReportContent="true"
.aspx文件添加到ReportViewer声明中,现在在Previewer中正确呈现了输出。没有它,就不会呈现任何内容,然后,一切就在那里!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句