Hi friends ,
I have a datgridaview named _gridview for data input . But when the value of cell[x,y] is set to null i can not write : _gridview.rows[x].cell[y].value.tostring(); then system give me an error : not set to an instance of any object .
So , what should i do for that because user can make the cell null at anytime they want . Can I use my code like below and if yes , what override event should i put my code in :
if(_gridview.currentcell.tostring()==sysem.dbNull.value.tostring())
_gridview.currentcell.value="";
THANKS .
Datagridviewcell value in c#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

PJ MartinsRank #2,548 · 548 reputationPosted Jun 6, 2010, 7:14 AM EDT
string cellValue = (_gridview.Rows[x].Cell[y].Value == null ? string.Empty : _gridview.Rows[x].Cell[y].value.ToString());
Minh40 reputationPosted Jun 7, 2010, 3:28 AM EDT