hey guys, I'm creating a basket for an e-commerce site, im trying to total up the basket values within the 'cart' class and return the value back to the 'basket' page where the total will be shown. The total is fine but i cant seam to return the total back to the 'basket' page.
heres my basket page:
protected void basketTotal()
{
cart Cart = new cart(); //new instance of the cart
string order = Session["orderid"].ToString(); //order_id from session
int? total = 0;
Cart.basketTotal(Session["orderid"].ToString(), total.ToString()); //passing order_id and total tothe cart class
Label1.Text = (Convert.ToString(total)); //return value will go here
}
my cart class is as follows:
public string basketTotal(string order_id, string total)
{
using (api_basketDataContext apiTotal = new api_basketDataContext())
{
int orderid = (Convert.ToInt32(order_id));
int? count = 0;
var result3 = apiTotal.getBasketTotal
(
orderid,
ref count
);
foreach (var item in result3) //calculation of items
{
var price = item.product_price;
var qty = item.quantity;
var subtotal = price * qty;
int i = 0;
if (i < count)
{
total = (Convert.ToString(total + subtotal));
}
i++;
}
return (Convert.ToString(total));
}
}
the total is getting passed back to the parameters but this is not being passed back to the 'basket' page, is this even possible this way?
thanks.