Invoiceget data = new Invoiceget();
data.slno = DataGridView1.CurrentRow.Cells["Column1"].Value.ToString();
its showing the correct slno if i move mouse over data.slno
and mean time i am getting Null Object reference not set to an instance of an object
Null Object reference not set to an instance of an object
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Iftikar HussainRank #423 · 5.9K reputationPosted Jul 10, 2013, 2:02 AM EDT
Before assigning the value to your class object, can you display the value like this
var temp=DataGridView1.CurrentRow.Cells["Column1"].Value;
MessageBox.Show(temp);
Regards,
Iftikar
suhas setty137 reputationPosted Jul 10, 2013, 2:06 AM EDT
now from application file i hv to update database
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 10, 2013, 3:24 AM EDT
hi,
As per me, this error occurs when you trying to access null object's properties / methods / public attribute or converting null object into other type of object.
here i think DataGridView1.CurrentRow.Cells["Column1"].Value has null value and your are trying to call is Tostring Method.
try...
data.slno = Convert.Tostring(DataGridView1.CurrentRow.Cells["Column1"].Value);
hope this will help you.