L
lrobo01
I'm having a problem with Crystal report.net with ASP.NET.
The problem occurs when exporting the report. The report
uses a discrete parameter with multiple values. When the
report is loaded into the crystal report view it shows all
the values from the discrete parameter. But when I export the
report it only shows the values from the last discrete parameter value
enter.
My code is listed below:
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
' Start Loading Report
'CR(Variables)
Dim opTeam As String()
Dim crParameterValues As New ParameterValues
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscreteValue
Dim rangeVal As New ParameterRangeValue
CrystalReportViewer1.Visible = True
crReportDocument.Load(Server.MapPath("CrystalReport1.rpt"))
crReportDocument.SetDatabaseLogon("****", "****")
Dim t As System.Web.UI.WebControls.ListBox
If Session("ListBox2") Is Nothing Then
t = New ListBox
't.Item(0).Text = "All"
Else
t = Session("ListBox2")
End If
Dim ind As Integer
Dim CRdiscretevalue As New
CrystalDecisions.Shared.ParameterDiscreteValue
crParameterFieldDefinitions =
crReportDocument.DataDefinition.ParameterFields
crParameterFieldLocation =
crParameterFieldDefinitions.Item("Operator Team")
crParameterValues = crParameterFieldLocation.CurrentValues
paramField.ParameterFieldName = "Operator Team"
Dim paramDiscreteValue As ParameterDiscreteValue
paramDiscreteValue = New ParameterDiscreteValue
If t.Items.Count > 0 Then
For ind = 0 To t.Items.Count - 1
paramField.ParameterFieldName = "Operator Team"
discreteVal = New ParameterDiscreteValue
discreteVal.Value = t.Items(ind).Text
paramField.CurrentValues.Add(discreteVal)
Next
Else
paramField.ParameterFieldName = "Operator Team"
discreteVal = New ParameterDiscreteValue
discreteVal.Value = "All"
paramField.CurrentValues.Add(discreteVal)
End If
paramFields.Add(paramField)
crReportDocument.SetParameterValue("Operator Team",
discreteVal)
'Bind the report to the viewer
CrystalReportViewer1.ReportSource = crReportDocument
CrystalReportViewer1.ParameterFieldInfo = paramFields
CrystalReportViewer1.DataBind()
' End Loading Report
'Export Code
oStream = crReportDocument.ExportToStream( _
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
With Response
.ClearContent()
.ClearHeaders()
.Buffer = True
.ContentType = "application/pdf"
.AddHeader("Content-Disposition", "inline;
filename=Report.pdf")
.BinaryWrite(oStream.ToArray())
.End()
End With
The problem occurs when exporting the report. The report
uses a discrete parameter with multiple values. When the
report is loaded into the crystal report view it shows all
the values from the discrete parameter. But when I export the
report it only shows the values from the last discrete parameter value
enter.
My code is listed below:
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
' Start Loading Report
'CR(Variables)
Dim opTeam As String()
Dim crParameterValues As New ParameterValues
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscreteValue
Dim rangeVal As New ParameterRangeValue
CrystalReportViewer1.Visible = True
crReportDocument.Load(Server.MapPath("CrystalReport1.rpt"))
crReportDocument.SetDatabaseLogon("****", "****")
Dim t As System.Web.UI.WebControls.ListBox
If Session("ListBox2") Is Nothing Then
t = New ListBox
't.Item(0).Text = "All"
Else
t = Session("ListBox2")
End If
Dim ind As Integer
Dim CRdiscretevalue As New
CrystalDecisions.Shared.ParameterDiscreteValue
crParameterFieldDefinitions =
crReportDocument.DataDefinition.ParameterFields
crParameterFieldLocation =
crParameterFieldDefinitions.Item("Operator Team")
crParameterValues = crParameterFieldLocation.CurrentValues
paramField.ParameterFieldName = "Operator Team"
Dim paramDiscreteValue As ParameterDiscreteValue
paramDiscreteValue = New ParameterDiscreteValue
If t.Items.Count > 0 Then
For ind = 0 To t.Items.Count - 1
paramField.ParameterFieldName = "Operator Team"
discreteVal = New ParameterDiscreteValue
discreteVal.Value = t.Items(ind).Text
paramField.CurrentValues.Add(discreteVal)
Next
Else
paramField.ParameterFieldName = "Operator Team"
discreteVal = New ParameterDiscreteValue
discreteVal.Value = "All"
paramField.CurrentValues.Add(discreteVal)
End If
paramFields.Add(paramField)
crReportDocument.SetParameterValue("Operator Team",
discreteVal)
'Bind the report to the viewer
CrystalReportViewer1.ReportSource = crReportDocument
CrystalReportViewer1.ParameterFieldInfo = paramFields
CrystalReportViewer1.DataBind()
' End Loading Report
'Export Code
oStream = crReportDocument.ExportToStream( _
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
With Response
.ClearContent()
.ClearHeaders()
.Buffer = True
.ContentType = "application/pdf"
.AddHeader("Content-Disposition", "inline;
filename=Report.pdf")
.BinaryWrite(oStream.ToArray())
.End()
End With