Server Error in '/' Application.

Object cannot be cast from DBNull to other types.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types.

Source Error:


Line 36:                 decimal Price = Convert.ToDecimal(ProductDt.Rows[0]["price"]);
Line 37:                 decimal Price_sar = Convert.ToDecimal(ProductDt.Rows[0]["price_sar"]);
Line 38:                 decimal Price_usd = Convert.ToDecimal(ProductDt.Rows[0]["price_usd"]);
Line 39: 
Line 40:                 txt_price.Text = String.Format("{0:#,#.0}", Price);

Source File: e:\hostingspaces\alyarmuk\alyarmuk.com\ProductDetails.aspx.cs    Line: 38

Stack Trace:


[InvalidCastException: Object cannot be cast from DBNull to other types.]
   System.DBNull.System.IConvertible.ToDecimal(IFormatProvider provider) +55
   System.Convert.ToDecimal(Object value) +33
   ProductDetails.LoadBasicInfoProduct() in e:\hostingspaces\alyarmuk\alyarmuk.com\ProductDetails.aspx.cs:38
   ProductDetails.Page_Load(Object sender, EventArgs e) in e:\hostingspaces\alyarmuk\alyarmuk.com\ProductDetails.aspx.cs:105
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0