查看水晶报告时发生NullReferenceException

时间:2011-09-16 22:53:18

标签: c# crystal-reports

我有一个每个dataGridView行的上下文菜单条,当我点击打印“P.O报告”时,它会打开一个水晶报告,这里是代码:

private void printPOToolStripMenuItem_Click(object sender, EventArgs e)
{
    string id = dataGridView1.CurrentRow.Cells[0].Value.ToString();
    POreport por = new POreport(Convert.ToInt32(id));
    por.Show();
}

这是POreport类的构造函数:

public POreport(int poId)
{
    this.crystalReportViewer1.SelectionFormula = "{poView.poId}="+poId;
}

但每次都会出现NullReferenceException

Object reference not set to an instance of an object.

0 个答案:

没有答案