473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Running totals in gridview (when you have many totals required)

Hi, Fairly easy to create one running total for a gridview but what if you
have dozens of them?

I have a gridview that allows bulk editing (all rows at once) and have it
set up so that, on data binding, totals are created for all of the dozens of
columns.

However I need to have it so that any time someone changes a number in one
of the textboxes the totals recalculate (columns need to add up to 100% so
the totals act as a guide to users of whether the values total correctly).
Can anyone suggest the best general approach for this client-side feature?

TIA,

Rob
Feb 15 '07 #1
3 2800
On Feb 15, 9:46 pm, Robert Chapman
<RobertChap...@discussions.microsoft.comwrote:
Hi, Fairly easy to create one running total for a gridview but what if you
have dozens of them?

I have a gridview that allows bulk editing (all rows at once) and have it
set up so that, on data binding, totals are created for all of the dozens of
columns.

However I need to have it so that any time someone changes a number in one
of the textboxes the totals recalculate (columns need to add up to 100% so
the totals act as a guide to users of whether the values total correctly).
Can anyone suggest the best general approach for this client-side feature?
client-side = JavaScript

You need to fire a javascript onchange and get the values from each
textbox.

I think you can find this thread helpful
http://p2p.wrox.com/topic.asp?TOPIC_ID=51682
Feb 15 '07 #2
Hi Alexey,

I've seen that thread and am comfortable with using javascript to add a
running total for specific textboxes. I get less sure of what to do when
there are 50 columns to total and the number of rows is variable. What works
well for one total doesn't really work for 50, so I just need a little
guidance as to what route to take.

Regards,

Rob

"Alexey Smirnov" wrote:
On Feb 15, 9:46 pm, Robert Chapman
<RobertChap...@discussions.microsoft.comwrote:
Hi, Fairly easy to create one running total for a gridview but what if you
have dozens of them?

I have a gridview that allows bulk editing (all rows at once) and have it
set up so that, on data binding, totals are created for all of the dozens of
columns.

However I need to have it so that any time someone changes a number in one
of the textboxes the totals recalculate (columns need to add up to 100% so
the totals act as a guide to users of whether the values total correctly).
Can anyone suggest the best general approach for this client-side feature?

client-side = JavaScript

You need to fire a javascript onchange and get the values from each
textbox.

I think you can find this thread helpful
http://p2p.wrox.com/topic.asp?TOPIC_ID=51682
Feb 16 '07 #3
On Feb 16, 11:57 am, Robert Chapman
<RobertChap...@discussions.microsoft.comwrote:
Hi Alexey,

I've seen that thread and am comfortable with using javascript to add a
running total for specific textboxes. I get less sure of what to do when
there are 50 columns to total and the number of rows is variable. What works
well for one total doesn't really work for 50, so I just need a little
guidance as to what route to take.
If I understand it right it might be following

in codebehind you will add onchanged JS with reference to some JS to
recalculate total

In the same time you can calculate the current total, number of rows,
etc. and set it to a public variable, which can be used later in
client side JS.

-- javascript --

var numberOfRows=<%=numberOfRows%>

.....

Depends on implementation, if you have a maximum possible number of
rows (say <25) you may not need to have the numberOfRows because you
can enumerate your rows like

for (var i=1;i<25;i++) {
if (mytextbox == null) {
return; // if you have a null between 1..25 it means you have less
rows
} else {
total += mytextbox.value;
}
}

I think that you need a similar solution, as in the following thread:
http://groups.google.com/group/micro...adfd47b1745c36

Feb 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: KashMarsh | last post by:
Trying to show running totals on a report, except it needs to show one total amount and values being subtracted from it. For example, the report shows a Total Inventory amount (TotInvAmt). And...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
0
by: John | last post by:
I have a gridview where I need to add totals for each grouped data, example my grid looks like this Sales 2006: BMW 100 Lexus 75 Mercedes 70 Total Sales: 245
3
by: igotyourdotnet | last post by:
I'm using a gridview and I have it formatted using sub headings. now I need to get totals for each sub heading. Is this possible? example: BMW (sub heading) 25,000 14,252 25,000 total:...
3
by: mochatrpl | last post by:
I am looking for a way to make a query / report display the running average for total dollars. I have already set up a query to provide totals dollars per day from which a report graphly shows...
9
by: JJM0926 | last post by:
I'm trying to create a running totals query in access 97. I have followed the directions on how to do it from Microsofts website article id 138911. I took their code they had and replaced it with...
6
by: Stuart Shay | last post by:
Hello All: I have a array which contains the totals for each month and from this array I want to get a running total for each month decimal month = new decimal; month = 254; (Jan) month =...
3
by: tshad | last post by:
I am building a GridView that is displaying some money values in 3 columns. I want to put the totals of each column in a label field (one for each column) in the footer. I was trying to figure...
3
by: Mike | last post by:
On my gridview I need to a add a new row that will have totals of a previous rows. It will be something like this row1 1 2 3 4 9 10 11...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.