locked
crystal report viewer ask to enter parameters when clicking print RRS feed

  • Question

  • User-1661247727 posted

    I have crystal report viewer on my page and has parameter field that gets data when user clicks Select command in gridview. I get data loaded up in the CR when select is clicked but when I hit print it ask print to PDF and then I click Export now it prompts me again to enter the Parameter value. which I don't want. Can some one help me out?

    I place the code in GridView's selected index change event.

     Protected Sub GridView5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView5.SelectedIndexChanged
            Label1.Text = GridView5.SelectedRow.Cells(1).Text   'just for testing 
    
            ' Loads data in Crystal Report to print 6x4 Labels
            
            If Me.Label1.Text.Trim.Length > 0 Then
                Me.CrystalReportViewer1.ReportSource = Server.MapPath("~/label4x6.rpt")
    
                Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo
                Dim wo_order As New ParameterField
                wo_order.Name = "wo"
    
                Dim wo_order_Value As New ParameterDiscreteValue
                wo_order_Value.Value = GridView5.SelectedRow.Cells(1).Text 
                wo_order.CurrentValues.Add(wo_order_Value)
                ParamFields.Add(wo_order)
    
    
            End If
    
        End Sub


     

    Wednesday, May 6, 2015 2:41 PM

Answers

  • User-1661247727 posted

    ended up finding some other method that's working now. printing from crystal report and exporting is working now.

    in case someone have similar issue here is the code I changed to get it working.

    Protected Sub GridView5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView5.SelectedIndexChanged
            Label1.Text = GridView5.SelectedRow.Cells(1).Text   'just for testing 
    
            ' Load the selected report file.   THIS CODE WORKS FOR PRINTING FROM CR VIEWER         '
            Dim cryRpt As New ReportDocument
            cryRpt.Load("C:\inetpub\wwwroot\ABC\label4x6.rpt")
    
            Dim crParameterFieldDefinitions As ParameterFieldDefinitions
            Dim crParameterFieldDefinition As ParameterFieldDefinition
            Dim crParameterValues As New ParameterValues
            Dim crParameterDiscreteValue As New ParameterDiscreteValue
    
            crParameterDiscreteValue.Value = Label1.Text
            crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
            crParameterFieldDefinition = _
                crParameterFieldDefinitions.Item("wo")
            crParameterValues = crParameterFieldDefinition.CurrentValues
    
            crParameterValues.Clear()
            crParameterValues.Add(crParameterDiscreteValue)
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
    
            CrystalReportViewer1.ReportSource = cryRpt
            ' CrystalReportViewer1.RefreshReport()
    
    
        End Sub

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 6, 2015 5:50 PM