I am encountering an issue with a gridview
that contains a row where integer values, such as 7000
, are being added.
My goal is to calculate the total of all these rows and display it in a textbox
after 2-3 rows have been added.
To achieve this, I have implemented the following code snippet:
if (document.getElementById('txtTotalExp').value == "") {
var Expense = 0;
} else {
var Expense = document.getElementById('txtTotalExp').value;
}
for (var i = 0; i < GridExpInfo.Rows.length; i++) {
var totAmount = GridExpInfo.Rows[i].Cells[7].Value;
var totval = totAmount;
Expense += parseInt(totval);
}
document.getElementById('txtTotalLandVal').value = parseInt(TotalPayableValue) + parseInt(Expense);
However, when checking the textbox, I am seeing a result like 200010001512.
It seems that the addition operation is not functioning correctly.