#region Get Cart

        if (Session["MyCart"] != null)
        {
            if (Session["MyCart"].GetType().Name.StartsWith("List"))
            {
                cart = (List<Cart>)Session["MyCart"];
            }
        }


        city.ShippingCharges = Common.ConvertToDecimal(ordersAddress.ShippingCity);

        liCity = (from sc in liCity where sc.ShippingCharges.Equals(city.ShippingCharges)select sc).ToList();

        //liCity = (from sc in liCity where sc.Name.Equals(ordersAddress.ShippingCity) && sc.StateID.Equals(ordersAddress.ShippingStateID) select sc).ToList();

        int TotalItem = 0;
        foreach (Cart c in cart)
        {
            TotalItem = TotalItem + c.Quantity;
            c.ShippingCharges = (Single)(c.Quantity * (decimal)liCity[0].ShippingCharges);
            c.NetAmount = ((c.Amount - c.PromotionAmount) + c.TaxAmount1 + c.TaxAmount2 + (Single)(liCity[0].ShippingCharges) + c.HandlingCharges);
        }


        #endregion Get Cart

Please first debug and add watch to see the result of each statement. Get the exception and if it still not understandable for you, give it to us with line number where the error is.

hye man which line you this error

1. if in this

if (Session["MyCart"] != null)
          {
             if (Session["MyCart"].GetType().Name.StartsWith("List"))
            {
               cart = (List<Cart>)Session["MyCart"];
            }
          }

means first you want to assign session value or use try catch

2.if in another part means fully check all objects having references created using "new" keyword

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.