asp.net 中 crystal 报告的空白结果问题

blank result problem with crystal report in asp.net

我正在使用 visual studio、ASP.NET。在我的项目中,我应该使用 crystal 报告。很遗憾 当我在 asp.net 中使用 crystal 报告时,结果显示空白页。

我的Html代码:

<head runat="server">
<title>Crystal Report From More Than One Table</title>
</head>
<body>
<form id="form1" runat="server">
<table cellpadding="10" cellspacing="10" width="70%" height="300px" align="center"
style="border: solid 2px gray;">
<tr>
<td align="center" style="background-color: SkyBlue;">
<span style="font-family: Times New Roman; font-size: 18pt; color: Green;">Customer
Product Order Detail Report</span>
</td>
</tr>
<tr>
<td align="center">
<asp:Panel ID="pnlReport" runat="server" Height="400px">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
</asp:Panel>
</td>
</tr>
</table>
</form>
</body>

我的CS代码(后面的代码):

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(Server.MapPath("EmployeeCrystalReport.rpt"));
CrystalReportViewer1.ReportSource = cryRpt;
}
}

该代码是正确的,但您应该再执行两个步骤:

1) 在 C:\inetpub\wwwroot\aspnet_client\system_web_0_30319 上复制名为 crystalreportviewers13 的文件夹并将其粘贴到 project root folder 中,如下所示 visual studio:

右击你的项目名称,然后selectOpen Folder On File Explorer

将名称为 crystalreportviewers13 的文件夹粘贴到此地址(项目根目录)

粘贴后,返回visual studio中的解决方案,如果该文件夹被隐藏,您可以这样做:

单击Show All File按钮

然后右键单击名称为 crystalreportviewers13 且没有颜色图标的文件夹,然后选择 Include In Project

2) 在您的 html 主页上添加此 javascript:

<script type="text/javascript" src="/crystalreportviewers13/js/crviewer/crv.js"></script> 

尽情享受吧!