Solved

Refresh Crystal Report after Print taken

Posted on 2011-03-03
5
608 Views
Last Modified: 2012-05-11
hi,

I have one report developed in .net application. Now say a user views the report and wish to print that report. hence for printing we have used our own Print Button and not the Crystal Report viewer default print button as we need to store the print date in database (which is today's date).

Said that, now when the print button is clicked, i wish the report to be refresh. I have tried Crystal Report.Refresh and ReportRefresh. The refresh does nothing while report refresh does refresh BUT it asks for the parameter (prompt for all the parameters in the report)

hence, what should i do in this case?

I have attached my code for View button and print button.

Kindly have a look as to get an idea of how view and print works.

Thanks much!
View-Code.txt
Print-Code.txt
0
Comment
Question by:meispisces
  • 2
5 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 35031394
WHy do you feel the need to refresh the report?

Printing it will use the existing parameters and run the report with current data assuming you don't have saved data.

Refresh causes the report to discard the parameters and want new ones.

mlmcc
0
 
LVL 7

Author Comment

by:meispisces
ID: 35033796
@mlmcc: Because once the report is printed out, the report should become blank (showing no data in it). By blank, doesn't mean that the database should be cleared off.
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 500 total points
ID: 35038120
A method to handle this is to cache the parameters.  Then you reload and reapply the saved parameters.

Here's a piece of some code that does this:
crv is my crystalreportviewer control
I use a class called ParameterValuePairs that houses the parameter name and value.

rptPersistent = New CrystalDecisions.CrystalReports.Engine.ReportDocument
            rptPersistent.Load(_ReportPath)
            If Not Me.crv.ReportSource Is Nothing Then
                Dim rptTemp As CrystalDecisions.CrystalReports.Engine.ReportDocument = crv.ReportSource
                Dim PVP As ParameterValuePairs
                Dim PVS As CrystalDecisions.Shared.ParameterValues
                Dim PV As CrystalDecisions.Shared.ParameterValue
                Dim PVS2 As CrystalDecisions.Shared.ParameterValues
                arParameterValues = New ArrayList
                For Each pf As CrystalDecisions.Shared.ParameterField In rptTemp.ParameterFields
                    PVS = pf.CurrentValues
                    For Each pf2 As CrystalDecisions.Shared.ParameterField In rptPersistent.ParameterFields
                        If pf2.Name = pf.Name Then
                            PVS2 = pf2.CurrentValues
                            For Each PV In PVS
                                PVP = New ParameterValuePairs(pf.Name, PV)
                                PVS2.Add(PV)
                            Next
                        End If
                    Next
                Next
                rptTemp.Close()
                rptTemp.Dispose()
            End If
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35275389
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now