Best Aopproach At Totalling DataGrids

M

Mr Newbie

Hi,

I have tables which are going to display working hours ( Timesheet ) I was
wondering the best way to total them. The grid is filled with data from a
query bound to a table. Does anyone have any "Best Practices" to offer as a
solution. I need to total both down and across.

Many thanks
 
E

Edwin Knoppert

Item templates + on Rowadded (or similar) event keep a count.
Use a var in the page class and set it to 0 on load.
Then in the event add each value.
 
J

jhcorey

I don't think there's a best practice in this situation, but there's
many ways to accomplish this. If the datasource is a datatable or a
collection then you could iterate through these before you bind. With
a datatable you could add a column dynamically and populate it with a
total going across. You could also add a row for the total line at the
bottom.

Another option would be to accumulate counters in the grid's
itemdatabound event, assuming that the grid always appears on a single
page.
 
E

Edwin Knoppert

Hmm, prerender might be the best option.
Afaik it's based on current view/data.
 
E

Edwin Knoppert

I was thinking...
A hidden label or else can hold any value you want.
maybe this is an idea?
using a <div> you can hide it, but even an invisible (property) might be
even better.
It's code is not generated but for asp.net the control remains present.

I think i just found out a way to use this for my own benefit.
I'm sure it's equal to manipulating the common viewstate but easier to do
imo.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top