开发者

NullReferenceException occurs when viewing crystal report

开发者 https://www.devze.com 2023-04-05 06:04 出处:网络
I have a context menu strip for each dataGridView row, when I click on print \"P.O report\" it opens a crystal report, here is the code:

I have a context menu strip for each dataGridView row, when I click on print "P.O report" it opens a crystal report, here is the code:

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();
}

And here is the constructor for the POreport class:

public POreport(int poId)
{
    this.crystalReportViewer1.SelectionFormula = 开发者_JAVA百科"{poView.poId}="+poId;
}

But a NullReferenceException occurs each time:

Object reference not set to an instance of an object.
0

精彩评论

暂无评论...
验证码 换一张
取 消