Using Crystalreportviewer with parameters

May 8 2009 4:39 AM

Hi there.

I have the following code

private void button1_Click(object sender, EventArgs e)
{
   SetParameterFieldInfo(
"JobRequestNo", 200);
   crystalReportViewer1.RefreshReport();
}

private void SetParameterFieldInfo(String fieldName, int fieldValue)
{
  
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
   parameterDiscreteValue.Value = fieldValue;
   ParameterValues currentParameterValues = new ParameterValues();
   currentParameterValues.Add(parameterDiscreteValue);
   ParameterField parameterField = new ParameterField();
   parameterField.Name = fieldName;
   parameterField.CurrentValues = currentParameterValues;
  
ParameterFields parameterFields = new ParameterFields();
   parameterFields.Add(parameterField);
   crystalReportViewer1.ParameterFieldInfo = parameterFields;
}

OK, my problem is that when I execute the line to call SetParameterFieldInfo only, then nothing happens. When I call the RefreshReport() method, it prompts me for the parameter value, which I don't want. When I type in the parameter value, the report displays correctly, so the connections and stuff seems ok.

How can I have my update my report with the new parameters passed from code without having a popup asking for the parameter values?

Thanks