Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get Sum of Databound Table Column

Status
Not open for further replies.

phillyman

Technical User
Apr 15, 2001
9
CA
Does anyone know how to get the total sum of all the values in a databound column in a databound table?

I've got a table that's bound to an XML data island where one column lists a bunch of numbers. I would like to have a row at the bottom total up the numbers. Any ideas?

Scott Wilkinson
 
Scott,

I can't help with your question i'm afraid but you might be able to help with mine.

I'm trying to create a data bound table and although i'm connecting via SQL and not XML I think (or hope) the majority of the methods etc will be the same as i'm having trouble getting the table to pull the info through.

Would it be possible for you to put some sample code up for me to have a look at?

Thanks,
Andrew Appleton
 
Well,

Once you have a recordset on the page, let's call it 'rsPhoneData' with columns 'name' and 'phone', then you should be able to bind the table as below.

<table datasource=&quot;#rsPhoneData&quot;>
<tr>
<th>Name</th>
<th>Phone</th>
</tr>
<tr>
<td><span id=&quot;name&quot; datafield=&quot;name&quot;></td>
<td><span id=&quot;name&quot; datafield=&quot;phone&quot;></td>
</tr>
</table>

Hope this helps. Do you have a more specific question?

Scott
 
Scott,

This has helped thanks, it still doesn't work but it has helped. You code is slightly different to the code I originally had from the Microsoft site but I now think it is an error with Visual Interdev itself as it just will not work.

If I use an SQL statement I don't get any data and if I use a Database Object I get an error with the Recordset.asp file!

Can't seem to win.
 
This looks like client-side code, which I do not use. However, you should be able to compute the sum prior to the grid display, and either add it to the end of the XML data via the DOM, or pump it out below the table - but then column alignment can be a problem.

I have adjusted the Server-Side GridDTC code to provide an On-Total-Row event, where you can supply the final row of the table with any required values - but this will not help you guys.
(Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top