private void txtQuantity_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
int quantity = Convert.ToInt32(txtQuantity.Text);
double totalProd = price * quantity;
dr["Total"] = totalProd;
dr["Quantity"] = quantity;
for (int i = 0; i < gridViewProduct_Transac.Rows.Count; i++)
{
sum += Convert.ToDouble(gridViewProduct_Transac.Rows[i].Cells[7].Value);
}
double total = sum;
lblSubtotal.Text = total.ToString("#,##0.##");
lblTotalAmount.Text = total.ToString("#,##0.##");
lblTotal.Text = total.ToString("#,##0.##");
cboSearchBy.Focus();
txtQuantity.Text = "";
gridViewProduct_Transac.DataSource = dt;
}
}
Deepak VermaPosted Jul 3, 2014, 7:38 AM
May be you're updating the value of sum before this handler/function.
It'll be good if you attach a sample demo application / complete code.