在Crystal Reports中分页

时间:2012-10-02 02:14:30

标签: asp.net crystal-reports crystal-reports-2008

需要帮助。因为每次单击下一页或预览页面时,它总是从数据库中检索数据。我尝试将其放在If Not Page.IsPostBack Then...EndIf内,但它删除了数据。

以下是代码。

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Threading.Thread.CurrentThread.CurrentCulture = _datestyle

        Try
            If (Session("userID").ToString() = Nothing Or Session("userID").ToString() = "") Then
                Const script As String = "top.location='../logon.aspx';"
                Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "logon", script, True)
                Return
            End If
        Catch ex As Exception
            Const script As String = "top.location='../logon.aspx';"
            Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "logon", script, True)
            Return
        End Try

        If Not Page.IsPostBack Then
            _rptSvc = CType(Session("ServiceDue"), ClsRptServiceDue)
            _dsSvcDue = _rptSvc.RetrieveServiceDue()

            GenerateReport(_dsSvcDue)
        End If

    End Sub

    Private Sub GenerateReport(ByVal dataSet As DataSet) Implements IBasicReportPage.GenerateReport
        titleLab.Text = _xml.GetLabelName("EngLabelMsg", "BB-RPTSERVICE-TITLE")
        _rptSvc = CType(Session("ServiceDue"), ClsRptServiceDue)

        Dim strHead As String() = CType(Array.CreateInstance(GetType(String), 18), String())
        PopulateLabels(strHead)
        DefineDefaultValues(strHead)

        Try                
            With _clsReport
                .ReportFileName = "RPTServiceDueLstng.rpt"
                .SetReport(CrystalReportViewer1, dataSet, strHead)
            End With

        Catch err As Exception
            Response.Write("<BR>")
            Response.Write("Error Message: " & err.Message.ToString)
            Response.Write("<BR>")
            Response.Write("Source : " & err.Source)
            Response.Write("<BR>")
            Response.Write("Stack Trace Message: " & err.StackTrace)
        End Try

    End Sub

需要帮助这些家伙。谢谢!

1 个答案:

答案 0 :(得分:1)

您是否从报告工具使用Crystalreport查看器控件。有一个事件称为分页。调用您的私有方法在该事件中生成报告。