Method for assigning asp.net Crystal Report parameter fields to code
- 2021-06-28 12:21:35
- OfStack
An example of how the asp.net Crystal Report parameter field is assigned to the code is given.Share it for your reference.The implementation is as follows:
// Declares the variables required to pass parameters to the viewer control.
ParameterFields paramFields = new ParameterFields ();
ParameterField paramField = new ParameterField ();
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue ();
ParameterRangeValue rangeVal = new ParameterRangeValue ();
// No. 1 Parameters are discrete parameters with multiple values.Set the name of the parameter field, which must match the parameters in the report.
paramField.ParameterFieldName = " Customer Name ";
// Settings 1 And pass it to the parameter.
discreteVal.Value = "AIC Childrens";
paramField.CurrentValues.Add (discreteVal);
// Settings 2 And pass it to the parameter. discreteVal The variable is set to a new value so that previous settings are not overwritten.
discreteVal = new ParameterDiscreteValue ();
discreteVal.Value = "Aruba Sport";
paramField.CurrentValues.Add (discreteVal);
// Add this parameter to the parameter field collection.
paramFields.Add (paramField);
// No. 2 Parameters are area values. paramField The variable is set to a new value so that previous settings are not overwritten.
paramField = new ParameterField ();
// Set the name of the parameter field, which must match the parameters in the report.
paramField.ParameterFieldName = " Customer ID";
// Sets the start and end values of the range and passes the range to the parameter.
rangeVal.StartValue = 42;
rangeVal.EndValue = 72;
paramField.CurrentValues.Add (rangeVal);
// Will 2 Parameters are added to the parameter field collection.
paramFields.Add (paramField);
// Put the parameter field collection into the viewer control.
crystalReportViewer1.ParameterFieldInfo = paramFields;
Here are my own applications:
public void OnePage(CrystalReportViewer crystalReportViewer,int a)
{
ParameterFields paramFields = new ParameterFields();
ParameterField paramField = new ParameterField();
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();
// No. 1 Parameters are discrete parameters with multiple values.Set the name of the parameter field, which must match the parameters in the report.
paramField.ParameterFieldName = "ARC_I_ID";
// Sets the discrete value and passes it to the parameter.
discreteVal.Value = id;
paramField.CurrentValues.Add(discreteVal);
// Add this parameter to the parameter field collection.
paramFields.Add(paramField);
// Put the parameter field collection into the viewer control.
crystalReportViewer.ParameterFieldInfo = paramFields;
}
The first code has two parameter fields, and the second code has one.
I hope that the description in this paper will be helpful to everyone's asp.net program design.