Reputation: 492
I'm using this code:
DataTable table = new DataTable();
table.Columns.Add("Title");
dataGridView1.DataSource = table;
to populate my dataGridView
but I get a null reference exception
when I set the datasource
.
Upvotes: 2
Views: 529
Reputation: 246
Your dataGridView1 is most likely a NULL reference. To verify, set a breakpoint on the line and when you hit it, hover your mouse over dataGridView1.
Upvotes: 4