I was taken one grid view, in that gridview there is 6 text boxes are there (sun1b,mon1b,...... total1b), I want to add (sum) those textbox valus without ''ADD Button ''click . I need to add the text box values (Horizontal, vertical ) total, I attached the image, u r understanding purpose.

It is possible to add the text box values ? pls help me!!

6 Years
Discussion Span
Last Post by sufyan2011

Of course it is. Are the textboxes populated from a database or are they using user input? If working from a database you simply perform the calculation at the same time you populate the textboxes.
If it is from user input and you don't want a button press to be required its a little trickier. You would need to code up something in the last textbox that performed the adding function - how well this would work would depend on the data (is there anyway to know when the user has fiinished entering the data in the tetxbox?).


If you are good in javascript let me explain the soultion:

  1. Take the grid in javascript e.g.
    var tblGrid = document.getElementById("grdXXXXX");
  2. for (var i = 1; i < (TotalCount); i++) {
    CurrentRow = tblGrid.rows[i];
    firstcolumn = CurrentRow.children[0].children[0];
    secondcolumn = CurrentRow.children[1].children[0];
    thirdcolumn = CurrentRow.children[2].children[0];

  3. Add up all columns and assign it to your desire column.
  4. Make all processing given above as function.
  5. Attach this function to all of you textboxes except total on "OnBlur" or "ObFocusOut" or "OnClick" client side event.

Let me know if it helps.

Edited by pyTony: Fixed formating

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.