I would like to ask how I can contain the error I am getting "Object reference not set to an instance of an object.",nullreferenceException .I am trying to assign the value I am getting from the gridview to a variable. I get the error on the first line. how can I handle a situation when the value is null.I've tried using isnot Nothing but its still giving me the error and isdbnull wont work because I am not dealing with a datatable .
I only get this error when the gridview is still empty how can I handle this.
If Not IsNothing(ProductsRawMaterialGrid.GridViewElement.CurrentRow.Cells("PercentageInMix").Value) Then
PIM = ProductsRawMaterialGrid.GridViewElement.CurrentRow.Cells("PercentageInMix").Value
Else
PIM = FormatNumber("0.00", 2)
End If