How to assign values to parameter fields of the asp.net Crystal Report in the code, asp.net CRYSTAL REPORT
This document describes how to assign values to parameters of the asp.net Crystal Report in the code. Share it with you for your reference. The specific implementation method is as follows:
// Declare 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 (); // The first parameter is a discrete parameter with multiple values. Set the parameter field name, which must be consistent with the parameters in the report. ParamField. ParameterFieldName = "customer name"; // set the first discrete value and pass it to this parameter. DiscreteVal. Value = "AIC Childrens"; paramField. CurrentValues. Add (discreteVal); // set the second discrete Value and pass it to this parameter. The discreteVal variable is set as a new value, so that the previous settings will not be overwritten. DiscreteVal = new ParameterDiscreteValue (); discreteVal. Value = "Aruba Sport"; paramField. CurrentValues. Add (discreteVal); // Add this parameter to the parameter field set. ParamFields. Add (paramField); // The second parameter is the region value. The paramField variable is set as a new value, so that the previous settings will not be overwritten. ParamField = new ParameterField (); // set the parameter field name, which must be consistent with the parameters in the report. ParamField. ParameterFieldName = "Customer ID"; // set the start and end values of the range and pass the range to this parameter. RangeVal. StartValue = 42; rangeVal. EndValue = 72; paramField. CurrentValues. Add (rangeVal); // Add the second parameter to the parameter field set. ParamFields. Add (paramField); // put the set of parameter fields into the viewer control. CrystalReportViewer1.ParameterFieldInfo = paramFields;
The following are my applications:
Public void OnePage (CrystalReportViewer crystalReportViewer, int a) {ParameterFields paramFields = new ParameterFields (); ParameterField paramField = new ParameterField (); ParameterDiscreteValue discreteVal = new release (); // The first parameter is a discrete parameter with multiple values. Set the parameter field name, which must be consistent with the parameters in the report. ParamField. ParameterFieldName = "ARC_ I _ID"; // set the discrete value and pass it to this parameter. DiscreteVal. Value = id; paramField. CurrentValues. Add (discreteVal); // Add this parameter to the parameter field set. ParamFields. Add (paramField); // put the set of parameter fields into the viewer control. CrystalReportViewer. ParameterFieldInfo = paramFields ;}
The first code has two parameter fields, and the second code has a parameter field.
I hope this article will help you design your asp.net program.