on 05-04-2009 1:25 PM
Hi All,
I have a report that I run. When I select the values and run the report on my web site, it produces data. However, when I go to select the print button or export button on the Crystal Viewer, the exported file that is generated does not display the data that was generated in the Crystal Viewer. How do I successfully generate the export to contain the data that is displayed in the viewer? It seems to default to the values set in my CrystalReportViewer1_Init code.
Here's my code:
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Web
Partial Class _Default
Inherits System.Web.UI.Page
Dim parameterField As ParameterField
Dim parameterField2 As ParameterField
Dim report As New ReportDocument()
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
display_report()
End Sub
Protected Sub display_report()
parameterField.CurrentValues.Clear()
parameterField2.CurrentValues.Clear()
CrystalReportViewer1.ParameterFieldInfo.Clear()
report.Load("C:\report.rpt")
parameterField = report.ParameterFields("Group")
parameterField2 = report.ParameterFields("Date Range")
For Each li As ListItem In Me.ListBox1.Items
If li.Selected = True Then
' Add all parameters value here
parameterField.CurrentValues.AddValue(li.Value)
End If
Next
parameterField2.CurrentValues.AddRange(CDate(st_date.Text), CDate(en_date.Text), RangeBoundType.BoundInclusive, RangeBoundType.BoundInclusive)
End Sub
Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Init
report.Load("C:\report.rpt")
parameterField = report.ParameterFields("Group")
parameterField2 = report.ParameterFields("Date Range")
parameterField.CurrentValues.AddValue("")
parameterField2.CurrentValues.AddRange(Today, Today, RangeBoundType.BoundInclusive, RangeBoundType.BoundInclusive)
CrystalReportViewer1.ReportSource = report
End Sub
End Class
I am using VS 2008 and CR 2008 SP1.
Thank you in advance.
Here's something I was testing out. When I select a date range for only today and export the file, then it exports the data that I see in the viewer. Any other date range that I select, it will only view it but not export it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why do you load the report two times? I see report.Load("C: eport.rpt") in the Protected Sub display_report() and in Protected Sub CrystalReportViewer1_Init(ByVal sender As Object, ByVal e As System.EventArgs). You should only be loading the report once. Do that before you set any parameters, then set what ever operation you want to do on the report (set parameters, etc.,) and then set the report to the viewer.
Some resources that may help you out:
Samples
https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe
Tutorials:
Ludek
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.