我有一个包含 CrystalReportViewer 的普通 asp.Net 页面。我在 Page_Load 方法中使用以下代码来显示报告:
ReportDocument report = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
report.Load(Server.MapPath("Reports\\" + Request.Params[0]));
crConnectionInfo.ServerName = ConfigurationManager.AppSettings["ReportSQLServer"];
crConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["ReportSQLDatabase"];
crConnectionInfo.UserID = ConfigurationManager.AppSettings["ReportSQLUsername"];
crConnectionInfo.Password = ConfigurationManager.AppSettings["ReportSQLPassword"];
CrTables = report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
Session["Report"] = report;
rptViewer.ReportSource = report;
rptViewer.RefreshReport();
但是,无论我加载什么报告,它都会显示如下:
当我在 WinForms 应用程序中使用完全相同的逻辑来填充 CrystalReportsViewer 时,报表将按预期显示。
请告知我在 ASP.NET Web 表单中缺少哪些内容,以使报告正确显示。
最佳答案
我在 IE10 中遇到同样的问题,在 IE10 浏览器模式下,reportviewer 中显示的是垂直条纹而不是数据。
解决办法是切换“IE10兼容模式”,一切正常
关于ASP.Net CrystalReportViewer 仅渲染垂直线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13785228/