
If (checkBox3.Enabled & !String.IsNullOrEmpty(product3DropDown.Text)) calculate subtotal3 - only calculate if CheckBox is enabled LblMsg.Text = "Error (CalculateGrandTotal 2) - " + ex.Message LblProduct2Subtotal.Text = subtotal2.ToString("$#,#0.00") Subtotal2 = CalculateSubtotal(product2DropDown.Text, lblProduct2UnitPrice.Text) If (checkBox2.Enabled & !String.IsNullOrEmpty(product2DropDown.Text)) calculate subtotal 2 - only calculate if CheckBox is enabled uncommenting the following line may be useful for debugging LblMsg.Text = "Error (CalculateGrandTotal 1) - " + ex.Message LblProduct1Subtotal.Text = subtotal1.ToString("$#,#0.00") Subtotal1 = CalculateSubtotal(product1DropDown.Text, lblProduct1UnitPrice.Text)

If (checkBox1.Enabled & !String.IsNullOrEmpty(product1DropDown.Text)) calculate subtotal1 - only calculate if CheckBox is enabled (i.ToString()) ĭecimal subtotal1 = 0m //use 'm' for decimalĭecimal subtotal2 = 0m //use 'm' for decimalĭecimal subtotal3 = 0m //use 'm' for decimal protected void Page_Load(object sender, EventArgs e) Subtotal3.Text = Convert.ToString(Convert.ToInt32(Qt圓.Text) * Convert.ToInt32(unitprice3.Text)).ToString() Protected void Product3DropDown_SelectedIndexChanged(object sender, EventArgs e) Subtotal2.Text = Convert.ToString(Convert.ToInt32(Qty2.Text) * Convert.ToInt32(unitprice2.Text)).ToString() Protected void Product2DropDown_SelectedIndexChanged(object sender, EventArgs e) Subtotal1.Text = Convert.ToString(Convert.ToInt32(Qty1.Text) * Convert.ToInt32(unitprice1.Text)).ToString() Protected void Product1DropDown_SelectedIndexChanged(object sender, EventArgs e) Product3DropDown.Enabled = CheckBox3.Checked Protected void CheckBox3_CheckedChanged(object sender, EventArgs e) Product2DropDown.Enabled = CheckBox2.Checked Protected void CheckBox2_CheckedChanged(object sender, EventArgs e) Product1DropDown.Enabled = CheckBox1.Checked Protected void CheckBox1_CheckedChanged(object sender, EventArgs e) LabelTOTAL.Text = (int.Parse(Subtotal1.Text) + int.Parse(Subtotal2.Text) + int.Parse(Subtotal3.Text)).ToString()
#GRANDTOTAL 3 CODE#
Here is my C# code protected void Page_Load(object sender, EventArgs e) I tried to calculate the total by adding the subtotals but it's not working. Product Unit Price Quantity SubTotal GrandTotal Finally, all the values of SubTotal Labels will be added and the result will be displayed in the GrandTotal Label. When a user clicks on any of the Checkboxes, the DropDown attached to that clicked Checkbox will be enabled and when user selects quantity from DropDown, the value of Unit Price Label will be multiplied by the value in the quantity DropDown and output the result in SubTotal Labels. On page load, DropDown will be disabled, Unit Price Labels will have values as "100", "200" and "100" respectively and the 3 SubTotal Labels will have initial values as "0", and GrandTotal Label will be "0". 3 Labels for Unit Price, 3 Labels for SubTotal and one Label for GrandTotal. The DropDowns are for Quantity, Labels are for Unit Price, SubTotal and GrandTotal.

The way I designed it is that I have 3 Checkboxes, 3 DropDowns controls and 7 Label controls.
#GRANDTOTAL 3 FULL#
Here is the full description of what I am trying to achieve.
