There are many cases in crystalreportviewer when we want to refresh the current report to get the new data, it always shows the parameter value form to ask the parameter value.
Currently I'm using crystalreport that was embedded from the microsoft visual studio 2005.
Although the button refresh is originally from the crystalreportviewer toolbar, but it wont automatically refresh without asking the parameter value, I have seen so many forum explaining this problem, but I cannot find the solution for this.
Finally I found out a way to solved this problems, There are 2 ways actually to solved this problem,
First is we make 1 dummy paramater, so everytime we click the refresh button, we always send the dummy parameter with different value from the previous value. By using this way, the crystalreportviewer will detect there is a changes in parameter value and it will refresh the data.
I know this way is not a good way, btw, another simple way is:
In button refres handle put this code:
Private Sub CrReportViewer_ReportRefresh(ByVal source As Object, ByVal e As CrystalDecisions.Windows.Forms.ViewerEventArgs) Handles CrReportViewer.ReportRefresh
Dim rpt As Object e.Handled = True rpt = Me.CrReportViewer.ReportSource CrReportViewer.ReportSource = Nothing CrReportViewer.ParameterFieldInfo = rpt.ParameterFields rpt.Refresh() CrReportViewer.ReportSource = rpt
End Sub
As you can see, I create a new object called rpt, get the all value from the current reportviewer, set it to nothing for report source, fill in again the parameter fields, refresh the object (This is the key) and put it back into reportsource.
Try it, and feels the heaven.
Regards Redsouljaz
|
No responses found. Be the first to respond and make money from revenue sharing program.
|