Add autocalculate summation row and column in asp.net Listview

lahue

New Member
I'm trying to create ListView which contains ASPxTextBox that the user can enter only numeric value. There are many rows and columns of data. I want to add new row and column that calculate total value from each row and columnFor example, if I have data like this:Student Name | Subject1 | Subject2 | Subject3
----------------------------------------------------------
John ----------- | ------- 23 | --------45 | --------37
Smith ---------- | ------- 41 | --------22 | --------11
Linda ---------- | ------- 35 | --------38 | --------23
I want to be like thisStudent Name | Subject1 | Subject2 | Subject3 | Total
------------------------------------------------------------------
John ----------- | ------- 23 | --------45 | --------37 | 105
Smith ---------- | ------- 41 | --------22 | --------11 | --74
Linda ---------- | ------- 35 | --------38 | --------23 | --96
------------------------------------------------------------------
Total----------- | --------99 | -------105 | --------71 | 275The number of columns (Subject) is fixed but the number of rows depends on data in database.There are 2 main problems here:
1. I want the summation row and column to execute calculation in client side using javascript. So when one of textboxes is lost focus, it will recalculate the summation value in each row and column.
2. I can't access the value from ASPxTextBox using javascript. I tried using:\[code\]var test = document.getElementById('<%# Container.FindControl("txt_Subject1").ClientID %>')var data = http://stackoverflow.com/questions/12598635/test.value;\[/code\]but it doesn't seem to work.The following code also cause error:\[code\]var test = document.getElementById('<%# Container.FindControl("txt_Subject1").ClientID %>') var data = http://stackoverflow.com/questions/12598635/test.GetValue();\[/code\]And when I tried ClientInstanceName, it always return the value of the last row only:\[code\]var data = http://stackoverflow.com/questions/12598635/txt_Subject1.GetValue(); //doesn't work?\[/code\]Also, I don't want to change ASPxTextBox to asp TextBox because I want to use some of its feature.
 
Back
Top