Subject: Crystal Report Parameter Problem
Posted By: donsls Post Date: 9/17/2006 8:03:33 PM
I have written a web application to display all parameters in a crystal report when selected and display the report.
In one of my reports I have a parameter called Rank. This parameter accepts values from 1 - 3. I have added these values in the set default values in crystal.
Also to make it readable to user, for each value I have added the description (Excellent for 1, Good for 2 and , Average for 3).
So when the report is refreshed in crystal it shows the Description instead of the values.
I have 2 problems.
1. In my web application, I cannot show the description of default values in my application. My code displays only the default values. I am not sure how to get the Description to show.
2. When I display the report, crystal report viewer alocates a certain area for the Group Tree.
Is it possible to change the width of this?
I am using Visual Studio.NET 2003 with Crystal 9 (Which is included in the Visual Stuydio installation)

Dim reportname As String = Server.MapPath("") & "\crystalreport1.rpt"
Dim rpt As New ReportDocument
rpt.Load(reportname)

Dim crParameterFieldDefinitions As ParameterFieldDefinitions
crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields()
Dim i As Integer = 0, j As Integer = 0
For i = 0 To crParameterFieldDefinitions.Count - 1
    For j = 0 To crParameterFieldDefinitions.Item(i).DefaultValues.Count - 1
        Response.Write(crParameterFieldDefinitions.Item(i).DefaultValues(j))
    Next
Next

I am stuck with this for the past 2 months.
Any help is greatly appreciated.


donsls
Reply By: dparsons Reply Date: 9/17/2006 9:40:56 PM
First, the Tree is always displayed on the left hand side of the CR Viewer control and I know of no way to change that.

What do you mean by Description?  You mean what you have named your field in Crystal?

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  

Unless, of course, you want to hire me to do work for you.
Reply By: donsls Reply Date: 9/18/2006 5:49:04 PM
What I mean by Description is:
When you create parameters in Crystal you could enter default values for that parameter. And for each default value, you could enter a description for readability. Ex: My database table has a field called Rank. It accepts integer values (1, 2 and 3). If I create a parameter called rank in my crystal report and enter 1,2 and 3, and when user refheshes the report it will ask the user to select 1, 2 or 3. But the user doesn't know about what these values stand for. So to make user understand this, for each default value in Rank I enter a description. Excellent for 1, Good for 2 and , Average for 3. So user will see only Excellent, Good and Average. I want to get these values in my aspx page. Please help me with this. I am really stumped with this.

donsls
Reply By: dougc Reply Date: 9/29/2006 5:02:37 PM
This snippet creates a dropdownlist control for a Crystal
parameter with a list of values. It assumes that there are
no ranges defined for the parameter, only discrete values. The resulting drop down list displays the description, but returns the value of the parameter as the SelectedValue.

Note: crReportDocument is a loaded Crystal ReportDocument object. iParamNumber is the index to the report parameter.


Dim paramField As ParameterFieldDefinition
Dim paramDefaultValues As ParameterValues
Dim paramDefaultValue As ParameterValue
Dim paramDefaultDiscreteValue As ParameterDiscreteValue
Dim paramChoiceValues As ParameterValues
Dim paramChoiceValue As ParameterValue
Dim paramChoiceDiscreteValue As ParameterDiscreteValue
Dim valueNdx As Int16

' Get the specified parameter
paramField = crReportDocument.DataDefinition.ParameterFields(iParamNumber)

' Get the default values (list of choices) from the parameter field
paramChoiceValues = paramField.DefaultValues

Select Case paramField.ParameterValueKind
    Case Is = ParameterValueKind.StringParameter
         If paramChoiceValues.Count > 0 Then
               ' String - choose from list.
               Dim ctlInput As New DropDownList
               ctlInput.ID = paramField.Name

               For Each paramChoiceValue In paramChoiceValues
                    paramChoiceDiscreteValue = paramChoiceValue
                    Dim lItem As New ListItem
                    lItem.Value = paramChoiceDiscreteValue.Value
                    lItem.Text = paramChoiceDiscreteValue.Description
                    ctlInput.Items.Add(lItem)
               Next paramChoiceValue
          end if

     Case .....
End Select



Reply By: donsls Reply Date: 10/10/2006 9:22:35 AM
Thanks for the reply. Much appreciated.

donsls

Go to topic 50822

Return to index page 152
Return to index page 151
Return to index page 150
Return to index page 149
Return to index page 148
Return to index page 147
Return to index page 146
Return to index page 145
Return to index page 144
Return to index page 143