If you are not certain with your input, you should use double.TryParse() method. If the user is not passing expected value then it would throw an error with
Convert.ToDouble() method.
But if we are certain that you will pass the only number then you can use Convert.ToDouble()
Convert.ToDouble will throw an exception on non-numbers
Double.Parse will throw an exception on non-numbers or null
Double.TryParse will return false or 0 on any of the above without generating an exception.
Try this
double price, quantity;
if(string.NullOrEmpty(txtPrice.Text)&&string.NullOrEmpty(txtQuantity.Text)
{
if (Double.TryParse(txtPrice.Text, out price)&&
Double.TryParse(txtQuantity.Text, out quantity))
{
double subTotal = 0;
subTotal = price * quantity;
txtSubTotal.Text = "" + subTotal.ToString();
}
}