如题。拉了一个未绑定字段,我想通过一个变量来为其赋值,如何实现?
CrystalReportViewForm crvf = new CrystalReportViewForm();
crvf.Show();
ReportDocument customersByCityReport = new ReportDocument();
string reportPath = Application.StartupPath+ "\\" + "xjglmc.rpt";
customersByCityReport.Load(reportPath);
customersByCityReport.SetDatabaseLogon(userid, userpwd, ipss, "jxxjglxt");
crvf.crystalReportViewer1.ReportSource = customersByCityReport;
SetCurrentValuesForParameterField(customersByCityReport, arrayList);
private void SetCurrentValuesForParameterField(ReportDocument reportDocument, ArrayList arrayList)
{
ParameterFieldDefinitions parameterFieldDefinitions =reportDocument.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions["SchoolName"];
ParameterValues currentParameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = School_Name;
//MessageBox.Show(School_Name);
currentParameterValues.Add(parameterDiscreteValue);
parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
parameterFieldDefinition.ApplyDefaultValues(currentParameterValues);
currentParameterValues = new ParameterValues();
foreach (object submittedValue in arrayList)
{
parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = submittedValue.ToString();
currentParameterValues.Add(parameterDiscreteValue);
}
parameterFieldDefinition = parameterFieldDefinitions["Students_Code"];
parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
}
里面有单值绑定,也有多值绑定,你看看吧.
[此贴子已经被作者于2006-10-14 10:50:55编辑过]