我已经阅读了所有可以找到的问题答案,但没有一个能解决我的问题。
我有一个代表我的数据行的类:
public class SimpleGeofenceReportDTO
{
public string AssetId { get; set; }
public string CompanyId { get; set; }
public string SiteId { get; set; }
public string CategoryId { get; set; }
public string StartDateTime { get; set; }
public string EndDateTime { get; set; }
public string GeofenceId { get; set; }
public string GeofenceEvent { get; set; }
public string EventDateTime { get; set; }
}
从Db读取数据并转换为DTO列表:
var reportList = geofenceReport.ToList();
var report = new List<SimpleGeofenceReportDTO>();
foreach (var geofenceRecord in reportList)
{
report.Add(new SimpleGeofenceReportDTO()
{
AssetId = geofenceRecord.iAssetId.ToString(),
CategoryId = geofenceRecord.iCategoryId.ToString(),
EndDateTime = geofenceRecord.dtUTCDateTime.ToString("dd/MM/yyyy"),
GeofenceId = geofenceRecord.iGeofenceId.ToString(),
GeofenceEvent = geofenceRecord.eEventCode == 6 ? "Geofence Enter" : "Geofence Exit"
});
}
我的报告CS代码:
var geofenceData = GETLISTOFGEOFENCEDTO();
GeofenceSummaryReportViewer.ProcessingMode = ProcessingMode.Local;
GeofenceSummaryReportViewer.LocalReport.EnableHyperlinks = true;
GeofenceSummaryReportViewer.HyperlinkTarget = "_blank";
GeofenceSummaryReportViewer.LocalReport.ReportPath = sPath;
GeofenceSummaryReportViewer.LocalReport.DataSources.Add(
new ReportDataSource("GroupGeofenceSummaryReportDataTable", geofenceData ));
GeofenceSummaryReportViewer.LocalReport.EnableExternalImages = true;
GeofenceSummaryReportViewer.LocalReport.Refresh();
ASP.NET WEbPage代码:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="ReportContentDiv" runat="server">
<rsweb:ReportViewer ID="GeofenceSummaryReportViewer" runat="server"
Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt" Width="98%" Height="98%">
<LocalReport ReportPath="TBReports\GeofenceSummaryReport.rdlc">
</LocalReport>
</rsweb:ReportViewer>
</div>
<div id="ErrorDiv" runat="server">
<span style="font-family: Arial; font-size: small; font-weight: bold">Your session has expired, Please login again and then try to generate this report.</span>
</div>
</form>
我调试了代码。数据从数据库返回,报告Div也显示在网页上,但没有数据。
我做错了什么?
答案 0 :(得分:0)
报告CS代码的最后一行:
GeofenceSummaryReportViewer.LocalReport.Refresh();
尝试将其更改为:
GeofenceSummaryReportViewer.RefreshReport();