命名空间为:using CrystalDecisions.Shared
private void BuildReportViewerParameters(CrystalDecisions.Web.CrystalReportViewer rptViewer, Hashtable ParamTable)
{
//定义报表视图的参数的方法
ParameterFields ParamFields = new ParameterFields();
foreach (object key in ParamTable.Keys)
{
ParameterField ParamField = new ParameterField();
ParameterValues ParamValues = new ParameterValues();
ParameterDiscreteValue ParamValue = new ParameterDiscreteValue();
ParamValue.Value = ParamTable[key].ToString();
ParamValues.Add(ParamValue);
ParamField.ParameterFieldName = key.ToString();
ParamField.CurrentValues = ParamValues;
ParamFields.Add(ParamField);
}
rptViewer.ParameterFieldInfo = ParamFields;