private void orderIDComboBox_SelectedIndexChanged(object sender, EventArgs e) { int selectedID = (int)orderIDComboBox.SelectedValue; try { current = OrderDB.GetOrderByID(selectedID); DisplayCurrentCustomerData(); ordDetails = OrderDetailsDB.GetOrderDetailIDs(selectedID); orderDetailDataGridView.DataSource = ordDetails; //ordDetails //Calculating order total float total = 0; foreach (OrderDetail order in ordDetails) { total += order.OrderTotal; } string Total = total.ToString(); textOrderTotal.Text = total.ToString("c2"); } catch (Exception ex) { MessageBox.Show("Error while retrieving customer with selected ID: " + ex.Message, ex.GetType().ToString()); } }