protected void btnCalculateOrder_Click(object sender, EventArgs e)
{
OrderSession();
if (IsValid)
{
double RetailPrice = Convert.ToDouble(lblRetailPrice);
double Quantity = Convert.ToDouble(txtQuantity);
double Tax = (.9);
double Subtotal = RetailPrice * Quantity;
double TotalAmount = Subtotal + Tax;
lblSubTotal.Text = Subtotal.ToString("c");
lblTotalAmount.Text = TotalAmount.ToString("c");
}
}
答案 0 :(得分:4)
挑剔,你不需要括号:
double Tax = (.9); //change to double Tax = .9; or double Tax = 0.9;
问题:
好像你想要Convert
Controls
而不是Text
的{{1}}
Controls
尝试将其更改为:
double RetailPrice = Convert.ToDouble(lblRetailPrice); //I assume this is a Label Control
double Quantity = Convert.ToDouble(txtQuantity); //and this is a TextBox Control