adding a "Sum Total" row to gridview?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I output a row for the Computed sums? I just want to append it as
a row at the bottom of my gridview table.
 
Thanks for the google search, but that's the first thing I tried. I'm using
'Compute' in my query which generates a row for computed sums. I was hoping
to use these values as, due to security reasons, I'm not allowed to place
code blocks on or behind the page.
 
'Fraid so. Working in a SharePoint environment that won't let me put code
blocks on the page. I can only use asp.net controls. And even then, I'm
limited. Suck to be me. but my hands are tied. That's why I'm trying to do
it all with SQL and controls.

I'm trying to find what I can get away with as far as customization, but
it's a tedious process.

CG
 
even something as simple as...
<ItemTemplate> <%# Eval("Nov") %> </ItemTemplate>

Breaks the page.

*sigh*
 
'Fraid so. Working in a SharePoint environment that won't let me put code
blocks on the page. I can only use asp.net controls. And even then, I'm
limited. Suck to be me. but my hands are tied. That's why I'm trying to
do
it all with SQL and controls.

Time to find another job...

I just can't imagine that sort of environment - how can you ever get
anything done...?
 
Time to find another job...
I just can't imagine that sort of environment - how can you ever get
anything done...?

You can't. but that doesn't stop them from asking for more.
 
Dump all the data into a temp table (make sure you add an identity
column) and then throw in your summation. Pull it out ordering by the
identity column on the temp table. Thats a dirty solution but it will
work.

Derek
 
You can't. but that doesn't stop them from asking for more.

Wow. I think Confucious said "First find people you can trust. And
then trust them". It must be horrible to be a developer in an
environment that doesn't trust developers.

Anyway, my solution would be similar to the "temp table" suggestion.
You'll probably have to do your summation it in SQL, so I'd suggest a
union query which would give you the total row at the bottom. Without
any code it's going to be hard to apply a different CSS class to style
the totals differently, but hey...

SELECT MyDate, ProductCode, Amount
FROM tb_sales

UNION ALL
SELECT NULL AS myDate, NULL AS ProductCode, SUM(Amount)
FROM tb_sales

Something like that, anyway.

HTH
 
Back
Top