Abdur Rahman
Abdur Rahman

Reputation: 667

Exception : Object reference not set to an instance of an object. Why?

Hello got the error in following code..enter image description here

The method RefeshDataGridView() is static.I run it in a separate thread to refresh the grid and get the latest data from DB table. I made dataGridView1 static because the method RefeshDataGridView() uses it. Can anyone describe why this error is occurred and how to solve it??

Update: If I make dataGridView1 non static then the error is gone.. But then I couldn't use it in the static method..

Upvotes: 0

Views: 376

Answers (1)

Larry
Larry

Reputation: 18031

I suppose dataGridView1 is null. You have to instanciate it or pass an instance of it as a parameter to RefreshDataGridView().

Upvotes: 2

Related Questions