Click here to Skip to main content
14,766,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to calculate sum of textboxes in single column of gridview using javaScript.
When value of any textbox changes the value will be automatically calculated with new one...

I tried the script

function CalculateTotals() {
           var grid = document.getElementById("rptExpense");
           var txt = document.getElementById("txtVFareTotal");
           for (var i = 0; i < 6; i++) {
               var val = grid.rows[i].columns[3].getElementById("txtexpense");

Plz help
Updated 18-Sep-13 0:17am
Thanks7872 18-Sep-13 5:04am
Have you tried some thing?
sumit wagh 18-Sep-13 5:12am
yes i tried so may ways but cant find textbox values in gridview
Thanks7872 18-Sep-13 5:14am
Use improve question widget above and post the relevant code you have implemented till now and point out the problem you faced/suspected.

1 solution

Hey Sumit,

You can use jquery which is easy to use and need to write less lines of code. Use any class like 'Amount' on text boxes and use that class in jquery selector.

function CalculateTotals() {
         var total=0;

I hope it will work for you.

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