NullReferenceException occurs when viewing crystal report
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.
精彩评论