Link to home
Start Free TrialLog in
Avatar of pascalmartin
pascalmartinFlag for Hong Kong

asked on

Crystal report navigation

I have a Crystal report that displays the result of two linked dropdownlists. The dropdownlist and report sub are nested in the page.ini sub while I have nothing in the page.load sub.
When i click the navigation button to go to the next page my report disapear. Can you help me to fix that? Here is my code:

Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        If Not IsPostBack Then
            If Not Session("SUBCATID") Is Nothing Then
                FillCat()
                ConfigureCrystalReports()
                ShowRept()
            Else
                FillCat()
                ConfigureCrystalReports()
            End If
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

 Private Sub ConfigureCrystalReports()
        CrystalReportViewer.HasPageNavigationButtons = True
        'CrystalReportViewer.ToolbarImagesFolderUrl = "~/Images"
        CrystalReportViewer.HasExportButton = False
        CrystalReportViewer.HasCrystalLogo = False
        CrystalReportViewer.HasToggleGroupTreeButton = False
        CrystalReportViewer.HasViewList = False
        CrystalReportViewer.HasPrintButton = False
        CrystalReportViewer.HasDrillUpButton = False
        CrystalReportViewer.HasSearchButton = False
        CrystalReportViewer.HasGotoPageButton = False
        CrystalReportViewer.HasZoomFactorList = False
        CrystalReportViewer.DisplayToolbar = True
        CrystalReportViewer.BorderWidth = 2
        CrystalReportViewer.BorderColor = Drawing.Color.DarkGreen
        CrystalReportViewer.DisplayGroupTree = False
        CrystalReportViewer.DisplayPage = True
        CrystalReportViewer.BestFitPage = True
    End Sub

 Sub ShowRept()
        Dim cryRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        Dim CrTable As CrystalDecisions.CrystalReports.Engine.Table
        Dim crtableLogoninfos As CrystalDecisions.Shared.TableLogOnInfo
        cryRpt.Load(Server.MapPath("~/CrystalReports/Catalogue1.rpt"), CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)

        For Each CrTable In cryRpt.Database.Tables
            crtableLogoninfos = CrTable.LogOnInfo
            With crtableLogoninfos.ConnectionInfo
                .ServerName = "MYSERVER"
                .DatabaseName = "MYDB"
                .UserID = "sa"
                .Password = "12345"
            End With
            CrTable.ApplyLogOnInfo(crtableLogoninfos)
        Next CrTable

             Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

       
        crParameterDiscreteValue.Value = ddlSubCat.SelectedValue.ToString
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("@SUBCATID")
        crParameterValues = crParameterFieldDefinition.CurrentValues

        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

        CrystalReportViewer.ReportSource = cryRpt
        btnPrnt.Visible = True
        btnPDF.Visible = True
    End Sub
Avatar of Ido Millet
Ido Millet
Flag of United States of America image

Avatar of pascalmartin

ASKER

Hi,
Please give me few day for implementing your solution, I have been extremely busy and not sitting at my desk for a while.
Best regards,
Hi Ido,
I have been able to place the report into a session, but when I click on the navigation button the report disappear and only reappear with the next page after a postback.
Avatar of Mike McCracken
Mike McCracken

Yes, navigation does do a postback which has to be handled in the code. I am not a .Net programmer so I don't know how to handle it.

mlmcc
Can you clean up this question as no valid resolution was provided
I've requested that this question be closed as follows:

Accepted answer: 0 points for pascalmartin's comment #a41422545

for the following reason:

Self resolution of the problem
How did you resolve the issue?

mlmcc
You were given one possible solution which you never really addressed as to if it works or not.  There was also a comment that agreed you do get a postback and you have to handle it to get to the next page of the report.

WHat is your solution to the issue?

If there is no solution in the comments (yours or the experts) this question is useless and should be deleted.

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of pascalmartin
pascalmartin
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is now a solution in the question.

It also appears you took my advice and handled the postback to solve the issue.

mlmcc
I solved the issue on my own no other solution offered could resolve the problem.