The problem in that code is that
row.Cells[ "Quantity" ].Value
can be
null
, but you call
ToString
on that without checking for that.
Change:
string.IsNullOrEmpty( row.Cells[ "Quantity" ].Value.ToString() )
to
string.IsNullOrEmpty( row.Cells[ "Quantity" ].Value as String)
Btw please don't do
!= true
, that's ugly to see and not recommended practice. Instead do this:
if( !String.IsNullOrEmpty(...))...