cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

I have run the the update to SP26 for some reason my parameters are no longer showing up in the parameter panel on the web crystalreportviewer after the report has initially loaded. The parameter(s) is prompted initially to run the report.

As a work around I have set HasToggleParameterPanelButton= false, HasRefreshButton=true, and ReuseParameterValuesOnRefresh=false.

<CR:CrystalReportViewer ID="Report" Runat="server" AutoDataBind="true" Height="1250px" HasCrystalLogo="False" HasRefreshButton="True" HasToggleParameterPanelButton="false" BestFitPage="True" ReuseParameterValuesOnRefresh="false" ToolPanelView="None" DisplayStatusbar="True" HasToggleGroupTreeButton="false" EnableDatabaseLogonPrompt="False" PrintMode="ActiveX" />

This does show the parameter(s) as expected. My report parameters are set to editable and when you loop through the parameterfield using the code below the Usage2 values is already set to all the available values (side note, this snip came from another post, but if you try it you will get a Not Supported exception)

foreach (CrystalDecisions.Shared.ParameterField parameterField in reportDocument.ParameterFields)
{
  parameterField.ParameterFieldUsage2 = ParameterFieldUsage2.ShowOnPanel;
}

As you can see from pic here the parameter for this report is missing from the Parameter Panel. Not sure how to fix this issue. Any suggestions would be appreciated. Thinking it might be a bug. I included my code below for reference. Prior to SP25 I was clearing the parameterfieldinfo property using Report.ParameterFieldInfo.Clear() in the report init method. This might have something to do with the missing parameters, but I have no way of testing, because if I add that back I cannot get the report to load as when you click the OK on the parameter dialog the report's ajax postback just returns the parameter dialog back instead of the rendered report.

 Private crReportDoc As ReportDocument
 Private rpt As String

    Private Sub Report_Init(sender As Object, e As System.EventArgs) Handles Report.Init
        Dim exportFormatFlags As Integer = CInt(CrystalDecisions.[Shared].ViewerExportFormats.PdfFormat Or CrystalDecisions.[Shared].ViewerExportFormats.ExcelFormat)
        Report.AllowedExportFormats = exportFormatFlags
        'Report.ParameterFieldInfo.Clear() 'started causing prompt to not go away if set 'removed 12/13/19 CR SP25 & SP26
        LoadCRV()
    End Sub
    Sub LoadCRV()
        Try
            rpt = Request.QueryString("rpt")
            If rpt Is Nothing Then Response.Redirect("~/reports/crm.aspx")
            Dim rptPath As String = Nothing
            If rpt IsNot Nothing Then rptPath = Server.MapPath("~/reports/cr/" + rpt)
            If rptPath IsNot Nothing Then
                Try
                    crReportDoc = New ReportDocument
                    crReportDoc.Load(rptPath)
                    For Each rd As ReportDocument In crReportDoc.Subreports
                        crDBLogin(rd)
                    Next
                    crDBLogin(crReportDoc)
                    Report.ReportSource = crReportDoc

                    Report.RefreshReport()
                Catch ex As CrystalReportsException
                Catch ex As Exception
                End Try
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub cr_Unload(sender As Object, e As System.EventArgs) Handles Me.Unload
        If rpt IsNot Nothing Then
            If crReportDoc IsNot Nothing Then
                If crReportDoc.Subreports IsNot Nothing Then
                    For Each srDoc As ReportDocument In crReportDoc.Subreports
                        If srDoc IsNot Nothing Then
                            srDoc.Close()
                            'srDoc.Clone() 'idea from web post
                            srDoc.Dispose()
                            GC.Collect()
                            'GC.WaitForPendingFinalizers() 'idea from web post
                        End If
                    Next
                End If
                crReportDoc.Close()
                'crReportDoc.Clone() 'idea from web post
                crReportDoc.Dispose()
                GC.Collect()
                'GC.WaitForPendingFinalizers() 'idea from web post
            End If
            If Report IsNot Nothing Then
                Report.Dispose()
            End If
        End If
    End Sub

Notes about my upgrade:

I ran the exe as the admin as instructed. I let it install the 64bit msi. The 32bit msi was already installed, but did not get updated. I updated it manually. The VS toolbox still has the .3500 controls referenced so I removed them and added the new items (not sure if that was suppose to happen automatically). I did remove all my references in the image below and added them back which updated the project file to the .4000 dll's.

Project Specs
x86, 4.7.2 framework

View Entire Topic
0 Likes

Hi Kevin,

Changing it back is not under our control, that is a specification by Microsoft as defined by the Page_Load and Page_Init.

A good explanation of how it works is here:

https://docs.microsoft.com/en-us/previous-versions...

Load should be used to preload all of the default's including PostBack methods and does not get called when you page through a report so the initial values are used. Page_Init refreshes the cached page and applies the update values, so it stays in scope. Otherwise the same values or no values are passed through the CR Next/Previous Page events.

If I get some time next week I'll do some testing as well, no one else has reported this being a problem so it's likely environmental.

Are you setting All CR Properties including log on properties in the Page_Init as well?

Try a simple test app and just page through it, with the viewer in the Page_Init section it should prompt for log on info once and then simply page through the report using Sessions/PostBack in the Page Init.

Actually if you just use these 3 lines in the Page_Init section it should prompt you for the dB log on info and then the Parameter values and then simple page through the report..

Looking closer at your test app I see now you are not using the Engine to load the report but simply using the Viewers Load event.

I'll have to find some old samples and see if does the same thing...

Don

kevin_hicks
Explorer
0 Likes

Hey don.williams hope all is well. I had to step away from this for a few days. I wanted to answer your question on the CR properties. I just ran through my code and everything is in the page_init. See code:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web

Partial Public Class cr
    Inherits System.Web.UI.Page

    Private rpt As String
    Private rd As ReportDocument

    Private Sub cr_Init(sender As Object, e As EventArgs) Handles Me.Init
        Dim exportFormatFlags As Integer = CInt(CrystalDecisions.[Shared].ViewerExportFormats.PdfFormat Or CrystalDecisions.[Shared].ViewerExportFormats.ExcelFormat)
        crReportViewer.AllowedExportFormats = exportFormatFlags

        rpt = Request.QueryString("rpt")
        If rpt Is Nothing Then Response.Redirect("~/reports/crm.aspx", False)

       If Session("ReportName") IsNot Nothing Then
            If Session("ReportName") <> rpt Then
                Session("ReportName") = rpt
                Session("Report") = Nothing
            End If
        Else
            Session("ReportName") = rpt
        End If

        If rpt IsNot Nothing Then
            crReportViewer.ID = rpt.Replace(".rpt", "")
        End If

        LoadReport()
    End Sub
    Private Sub cr_Load(sender As Object, e As EventArgs) Handles Me.Load
        'LoadReport() ''''not using this currently
    End Sub
    Private Sub LoadReport()
        If Session("ReportName") IsNot Nothing Then
            Dim reportName = Session("ReportName").ToString()
            Dim cachedReport As String = reportName + Session.SessionID

            If Session("Report") Is Nothing Then
                rd = New ReportDocument
                rd.Load(Server.MapPath("~/reports/cr/" + reportName))

                For Each srd As ReportDocument In rd.Subreports
                    crDBLogin(srd)
                Next
                crDBLogin(rd)

                Session("Report") = rd
                'Cache.Insert(cachedReport, rd, Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(20))
            Else
                rd = CType(Session("Report"), ReportDocument)
            End If

            If rd.ParameterFields.Count = 0 Then
                crReportViewer.ToolPanelView = ToolPanelViewType.None
            End If

            crReportViewer.ReportSource = rd
        End If
    End Sub
    Sub crDBLogin(ByVal rptDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument)
        Try
            Dim crCI As New CrystalDecisions.Shared.ConnectionInfo

            With crCI
                .ServerName = System.Configuration.ConfigurationManager.AppSettings("sqlserver")
                .DatabaseName = System.Configuration.ConfigurationManager.AppSettings("database")
                .UserID = System.Configuration.ConfigurationManager.AppSettings("user")
                .Password = System.Configuration.ConfigurationManager.AppSettings("pwd")
                .Type = CrystalDecisions.Shared.ConnectionInfoType.SQL
                .IntegratedSecurity = False
            End With

            For Each crTable As CrystalDecisions.CrystalReports.Engine.Table In rptDoc.Database.Tables
                Dim li As CrystalDecisions.Shared.TableLogOnInfo = crTable.LogOnInfo
                li.ConnectionInfo = crCI
                crTable.ApplyLogOnInfo(li)
            Next

            rptDoc.VerifyDatabase()
        Catch ex As CrystalDecisions.Shared.CrystalReportsException

        End Try
    End Sub
    Private Sub cr_Unload(sender As Object, e As System.EventArgs) Handles Me.Unload
        If crReportViewer IsNot Nothing Then
            crReportViewer.Dispose()
        End If
    End Sub
End Class

Based on my production code I am using the Engine. I am also using a method to logon to the database and set the EnableDatabaseLogonPrompt property to false on the viewer control.

<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="cr.aspx.vb" Inherits="MJHCRM.cr" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.4000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!doctype html>
<html lang="en">
<head>
    <title>Report Viewer</title>
</head>
<body>
    <form id="crForm" runat="server">
       <CR:CrystalReportViewer 
           ID="crReportViewer" Runat="server" AutoDataBind="True" Height="1250px" HasCrystalLogo="False" BestFitPage="True" DisplayStatusbar="False" ToolPanelView="ParameterPanel"
           EnableDatabaseLogonPrompt="False" 
           HasRefreshButton="True"
           ReuseParameterValuesOnRefresh="False"
           HasZoomFactorList="False"
           HasPrintButton="False" 
           HasDrillUpButton="False" HasDrilldownTabs="False" 
           Width="100%" BorderStyle="None" SeparatePages="True"
           />
        <asp:HiddenField runat="server" ID="current_page" />
    </form>
</body>
</html>

So I understand that you all cannot move your wiring up for the viewer back to the Page_Load method. I am thinking what happened is that the CR viewer development team overlooked how the optional parameters are loaded into state during the Page_Init. As I have stated and shown early on this thread the optional parameter state works correctly when moving my LoadReport method into Page_Load. However, when LoadReport is called from Page_Init the optional parameters get displayed on viewer postback (ie: next page, previous page, zoom, etc) I really just think the CR viewer developer team needs to give this a quick look. I just feel something to do with optional parameter state management was overlooked when migrating the code over to using Page_Init.

Thanks,
Kevin

kevin_hicks
Explorer
0 Likes

don.williams just circling the wagon to see if saw my previous post....thanks, Kevin