Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all;

I have one DataGrid. In that the user can add and remove the rows in that grid. So in this case in my datagrid i have one amount column.

Now,I need to loop that amount column and i need to sum it and i have to fill the summed value in one textbox(Total Amount) which is in the same form but outside the grid.

I have used the onkeyup property for the particular ItemBound Textbox(Amount) Column like onkeyup="SumValues();".

So how can i acheive this using JAVASCRIPT ..

Please help me.. Thanks in advance :-)

If my question is not understandable kindly revert me.. Waiting for the reply..

Thanks again...
Posted

1 solution

Refer this[^]
 
Share this answer
 
Comments
GANESH KUMAR K 12-Dec-12 8:13am    
Dear Rohit thank you for your response. In my office i dont have the access to that particular URL Which you have given. Anyway let me check with my home and Update you my result soon.. Thanks alot for being Responsible... :-)
IpsitaMishra 12-Dec-12 8:22am    
here is the code in the page


function GetTotal() {
totalDTH = 0;
totalMCF = 0;

// Get the gridview
var grid = document.getElementById("<%= grdVolumes.ClientID%>");

// Get all the input controls (can be any DOM element you would like)
var inputs = grid.getElementsByTagName("input");
// Loop through all the DOM elements we grabbed
for (var i = 0; i < inputs.length; i++) {

// In this case we are looping through all the Dek Volume and then the Mcf volume boxes in the grid and not an individual one and totalling them
if (inputs[i].name.indexOf("txtDekVolume") > 1) {
if (inputs[i].value != "") {
totalDTH = totalDTH + parseInt(inputs[i].value);
}

}
if (inputs[i].name.indexOf("txtMcfVolume") > 1) {
if (inputs[i].value != "") {
totalMCF = totalMCF + parseInt(inputs[i].value);
}

}
}
}
GANESH KUMAR K 13-Dec-12 2:37am    
Thank you IpsitaMishra for your help :-) Thanks alot :-) I got Output... Thanks again..
GANESH KUMAR K 12-Dec-12 23:10pm    
Very Good morning Rohit Thanks alot.. :-)
[no name] 13-Dec-12 0:09am    
If you're satisfied with the given answer, Accept the Solution :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900