onClick button sum columns items in datagrid

57 views Asked by At

every time onclick button is not sum all item in the columns it's just minus 1 item from the loop DtaGridAddInvBackBill.Items.Count - 1 when i try to remove - 1 it's get in error on the decimal sum += all i need to every time click add the item then sum the last column Inv ItemTotal then after sum put in the Textblock TotalItemcount

decimal sum = 0m;
for (int i = 0; i < DtaGridAddInvBackBill.Items.Count - 1;i++)
{
    sum += (decimal.Parse((DtaGridAddInvBackBill.Columns[10].GetCellContent(DtaGridAddInBackBill.Items[i]) as TextBlock).Text));
}
TotalItemcount.Text = " Invoice Total : ( " + Math.Round(sum, 2).ToString() + " )";  

enter image description here

0

There are 0 answers