PDA

View Full Version : Totals Row with DataGrid (.Net)


christrinder
06-23-2003, 02:35 PM
Hello,

I'm using a DataGrid, but does anybody know of an easy way to add a totals to the footer? I'm really beginng to hate ASP.Net, you can't even loop through, dynamically creating the variables to hold the totals figures. There must be a more direct way of doing this in ASP.Net? Unfortunately, I the table has 12 columns for which I need to generate totals. Any help would really be appreciated.

Cheers,
Chris

angiras
06-23-2003, 06:00 PM
I can understand that you hate .Net it's just like a pretty girl that you cannot get at once :))

for your case you can collect prices or integer you want easily and display them where you like , footer or not footer does not matter , I use a htmlTable to display the results, just after the datalist (I don't like datagrids)

you just do a loop throught all your textBoxes to calculate the total an display it where you like

you have a few models for datagrid here (http://www.aspng.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/doc_datagrid.aspx)

to bind your datagrind you will do a SELECT * FROM table1 WHERE ....

then just do a SELECT Sum on your request