我有一个包含CrystalReportViewer
的表单,顶部有两个DateTimePickers
和button1
,当我运行此代码并选择日期并点击按钮时,没有数据仅在查看器上显示列名称。
private void button1_Click(object sender, EventArgs e)
{
ByName cryrpt = new ByName();
cryrpt.Load(@"C:*******************ByName.rpt");
ParameterFields pfields = new ParameterFields();
ParameterField pfield = new ParameterField();
ParameterDiscreteValue pdisc = new ParameterDiscreteValue();
ParameterField pfield1 = new ParameterField();
ParameterDiscreteValue pdisc1 = new ParameterDiscreteValue();
pfield.Name = "start_Date";
pdisc.Value = FirstDate;
pfield.CurrentValues.Add(pdisc);
pfields.Add(pfield);
pfield1.Name = "End_Date";
pdisc1.Value = SecondDate;
pfield1.CurrentValues.Add(pdisc1);
pfields.Add(pfield1);
crystalReportViewer1.ReportSource = cryrpt;
crystalReportViewer1.ParameterFieldInfo = pfields;
FirstDate = dateTimePicker1.Value;
SecondDate = dateTimePicker2.Value;
crystalReportViewer1.ReportSource = cryrpt;
crystalReportViewer1.Refresh();
}