tags:

views:

74

answers:

2

Can anyone help explain why when I bind the following code to a gridview, the negative numbers come out as 0.00?

        var shoppingCartItems2 = Checkout.GetPropertyListingShoppingCartItems(SC.ShoppingCartID);

        var columns = from sci in shoppingCartItems2
                      select new { Description = sci.ShoppingCartItemTypeL.Description, Price = sci.ShoppingCartItemTypeL.Price, ShoppingCartItemID = sci.ShoppingCartItemID };
        ShoppingCartItemTypeGridView.DataSource = columns;
        ShoppingCartItemTypeGridView.DataBind();

The "Price" field in shoppingCartItems2 has the correct value for each of the returned items, but when I create a new object (columns) in order to bind further down the object chain, the negative price (a discount) shows on the gridview as 0. It still calculates the total price correct, and it is negative in the database.

Any ideas?

A: 

What type is sci.ShoppingCartItemTypeL.Price?

Have you tried casting it to an int? Price = (int)sci.ShoppingCartItemTypeL.Price?

Chalkey
A: 

It is type 'money'. I haven't tried casting it to an int, but will do so.

Josh