Monday, March 7, 2011

asp.net gridview, column total in footer using java script

Thanks to the author @ http://forums.asp.net/t/1168003.aspx
--------------------
In my grid I have one label in template field which stores item price, I want to show the total of items on label in footer.

function RetrievePackageDetailInputs() {
try {
var totVal = 0;
rows = document.getElementById('<%= gvCartDetails.ClientID %>').getElementsByTagName("TR");
for (var j = 1; j < rows.length - 1; j++) { cells = rows[j].getElementsByTagName("span"); if (cells.length > 0) {
totVal = Number(totVal) + Number(cells[0].innerHTML);
}
}
rows[rows.length - 1].getElementsByTagName("span")[0].innerHTML =CurrencyFormatted(totVal);
}
catch (er) {
// Non-critical error
alert(er.description);
}
}

No comments:

Post a Comment