【发布时间】:2019-02-25 03:54:31
【问题描述】:
我对在 Visual Studio 2017 上使用 Crystal Reports 创建报表有点陌生。 我使用设置向导在 VS2017 上创建了一个名为 PersonnelListingReport.rpt 的报告。通过向导,我选择了报告将基于的表。此外,我添加了一个过滤器参数,该参数将仅显示处于活动状态的员工,即(活动 = 1,非活动 = 0)。所以现在在我的主报告预览窗口中,我可以看到所有状态 = 1 的员工。我的问题是,当我在 GridView 上添加或删除项目时,更改不会反映在我的报告中。这是我的 Page_Load 中的内容:
Public Class PersonnelListingReportViewer
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim crystalReport As New ReportDocument()
crystalReport.Load(Server.MapPath("PersonnelListingReport.rpt"))
CrystalReportViewer1.ReportSource = crystalReport
End Sub
这是我在我的 aspx 下的 ReportViewer 的内容:
body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" GroupTreeImagesFolderUrl="" Height="1202px" ReportSourceID="CrystalReportSource1" ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="1104px" />
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="PersonnelListingReport.rpt">
</Report>
</CR:CrystalReportSource>
</div>
</form>
我的代码中是否缺少某些内容?我已经尝试根据论坛帖子使用 Refresh() 和 Load() 有类似问题但无济于事。我还阅读了有关创建 Page_Unload 的论坛帖子,然后让报告调用 Close() 然后 Dispose() 但也无济于事。我试过选中复选框以在加载报告时丢弃保存的数据,但仍然没有。我知道我遗漏了一些东西,但不太确定,因为这是我第一次在 Visual Studio 2017 上使用 Crystal Reports。谢谢大家!
【问题讨论】:
-
你试过 CrystalReportViewer1.DataBind() 吗? CrystalReportViewer1.RefreshReport()
-
Grid 事件后页面是否刷新?
-
@SreenathGanga 我已经尝试了这两行代码并且它正在工作,但是,在看到更新的报告之前,应用程序会提示数据库登录。如何在无需将数据库凭据放入后端代码的情况下查看更新的报告?
-
@JulyOrdinary 是的。我在事件之后绑定数据。
-
@Brian.Scalabrine 查看更新的答案
标签: asp.net vb.net gridview crystal-reports visual-studio-2017