1

在这方面需要帮助。因为每次我点击下一页或预览页面时,它总是从数据库中检索数据。我试着把它放进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

在这方面需要帮助。谢谢!

4

1 回答 1

1

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

于 2012-10-03T14:29:15.797 回答