13,044,115 members (82,740 online)
Rate this:
See more:
How to calculate the sum of column in grid view using java script
Posted 21-Oct-11 2:11am
vino12345 21-Oct-11 9:03am

* "grid_list" is my gridview id

* "cells[3]" is my column

Rate this:

## Solution 1

{
var str=0;
var Grid_Table = document.getElementById('<%=grid_list.ClientID%>');
for(var row=1; row<Grid_Table.rows.length; row++)
{
if(document.all)
str=str+Number(Grid_Table.rows[row].cells[3].innerText);

else
str=str+Number(Grid_Table.rows[row].cells[3].textContent);

}
return false;
}
Rate this:

## Solution 2

Check out this.....

function CalculateSum()
{
var grid = document.getElementById('<%=gvAttribute.ClientID %>');
var gridinput = grid.getElementsByTagName('input');
var sum = 0*1;

for(i = 0; i < gridinput.length; i++)
{
var value1 = gridinput[i].value;
sum = parseFloat(sum) + parseFloat(value1);
}
return parseFloat(sum);
}

Top Experts
Last 24hrsThis month
 OriginalGriff 230 ppolymorphe 140 Sheila Pontes 105 LuxGiammi 80 Afzaal Ahmad Zeeshan 70
 OriginalGriff 4,420 RickZeeland 1,834 ppolymorphe 1,574 F-ES Sitecore 1,553 Dave Kreskowiak 1,309