views:

18

answers:

1

Hello Friends, I am working with crystal report 2008

I have a Parameter Field named HeaderColumn1, whose value I want to pass programmatically.

I set the parameter field value with following code:

ReportDocument reportDocument = new ReportDocument();
ParameterFields paramFields = new ParameterFields;
ParameterField paramField;
ParameterDiscreteValue paramDiscreteValue;

paramField = new ParameterField();
paramField.Name = "HeaderColumn1";
paramDiscreteValue = new ParameterDiscreteValue();
paramDiscreteValue.Value = "Customer Code";
paramField.CurrentValues.Add(paramDiscreteValue);


paramFields.Add(paramField);

crystalReportViewer1.ReportSource = reportDocument;
crystalReportViewer1.ParameterFieldInfo = paramFields;
crystalReportViewer1.RefreshReport();

On running this code, it prompts for the ParameterValue of HeaderColumn1 parameter.

Why so ? Any solutions or suggestions ? Thanks a ton in advance.

:))

A: 

Solution:

It worked finally using following:

ReportDocument reportDocument = new ReportDocument();
ParameterFields paramFields = new ParameterFields;
ParameterField paramField;
ParameterDiscreteValue paramDiscreteValue;


paramField = crystalreportviewer1.ParameterFieldInfo["HeaderColumn1"];
paramDiscreteValue = new ParameterDiscreteValue();
paramDiscreteValue.Value = "Customer Code";
paramField.CurrentValues.Add(paramDiscreteValue);


paramFields.Add(paramField);


crystalReportViewer1.ReportSource = reportDocument;
crystalReportViewer1.ParameterFieldInfo = paramFields;
crystalReportViewer1.RefreshReport();
Niraj Doshi