ASP.Net MVC Error converting value null to type System.Decimal Null object cannot be converted to a value type

Last Reply one month ago By dharmendr

Posted one month ago

Hi,

based upon below url i am going to do save records on database

Save multiple records with uploaded file path for single user using AngularJS in ASP.Net MVC

Currently issue is that it was throwing error if i gave datatype = decimal

if datatype = deciaml value empty then it was throwing error

Error converting value {null} to type 'System.Decimal'

Null object cannot be converted to a value type

Ex:In my case EMI_Id is empty then it was throwing error

You are viewing reply posted by: dharmendr one month ago.
Posted one month ago

Hi mahesh213,

Make your EMI_Id nullable. Value null could not be serialized to decimal.

public decimal? EMI_Id;

Or you can ignore nulls while Serializing JSON.

string jsonString = JsonConvert.SerializeObject(movie, Formatting.Indented,
    new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });