paginationcrystal-reports

When viewing a report inside an application, the parameter prompt redisplays when moving to the next page


I'm pretty much a novice with crystal reports. We have another team making our reports, and I'm integrating it with the application. The problem is with paging and user defined parameters. Essentially, the document.table. setdatasource points at our query result set (set in code). The report, upon opening, will then prompt the user for the parameter, which will further reduce the displayed result to the user as the prompt parameter is part of the record selection formula.

AND
{@Age} >= 20 and
{@Age} < 30 and
{Report;1.Sector} = {?NewSector})

This will return a table of more than one page in length. However, requesting the next page will result in the user being prompted for the Sector again, and once provided, will take the user back to page 1 of the results again.

If I take out the reference to the parameter, then obviously the paging works fine.

Is there away to just take the parameter once from the user, and then reuse this value in the subsequent paging requests?

Appreciate your help...


Solution

  • Stupid me. I had the report refreshing every postback.

    EDit

    A bit more elaboration:

    I have the report being created in a RefreshReports procedure, which sets up the report as follows:

     Dim objConnectionInfo As CrystalDecisions.Shared.ConnectionInfo
        Dim crConnectionInfo As CrystalDecisions.Shared.ConnectionInfo
    
        Dim myconnection As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings(ApplicationConstants.MyDB).ConnectionString)
        Dim myConnBuilder As New SqlConnectionStringBuilder(myconnection.ConnectionString)
    
        '// Log on credentials from web.config
        objConnectionInfo = New CrystalDecisions.Shared.ConnectionInfo
        objConnectionInfo.IntegratedSecurity = False
        objConnectionInfo.ServerName = myconnection.DataSource
        objConnectionInfo.UserID = myConnBuilder.UserID
        objConnectionInfo.Password = myConnBuilder.Password
    
        crConnectionInfo = objConnectionInfo
    
    
        '// Get the report details needed
        rep = Request.QueryString("Report")
        crDoc.Load(Server.MapPath(rep))
        crDoc.SetDatabaseLogon(myConnBuilder.UserID, myConnBuilder.Password)
    
        Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
    
        Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
        Dim aTable As CrystalDecisions.CrystalReports.Engine.Table
    
        crDatabase = crDoc.Database
        crTables = crDatabase.Tables
    

    There is then a series of else ifs like the following:

    ElseIf rep = "ExampleRep.rpt" Then
            For Each aTable In crTables
                If aTable.Name = "GetSectorRep;1" Then
                    Dim NewSector As String = ""
                        NewSector = Session("NewSector").ToString()
                    aTable.SetDataSource(DAL.GetSectorRepTable(NewSector))
                End If
            Next
    

    In my Page_Init I grab the query strings I need and call RefreshReports. The problem I was having was that I was also requesting RefreshReports in a If Postback on page_load, which meant that every time the report posted back (eg. new page) it was requesting the parameter again, as the report was being created afresh.

    So, silly me - quite an obvious mistake in the end!