Display Datagrid group Subtotals

K

Kannan

Hello,
I am trying to achieve something in this format in a datagrid...
Apologize if the drawing is not very clear...


Make Model Value
===== ===== ======
Toyota Tercel 16000
15500
-------------------------------------------------
Total Tercel 31500
--------------------------------------------------
Corolla 18000
19500
---------------------------------------------------
Total Corolla 27500
---------------------------------------------------
Total Toyota 59000

----------------------------------------------------
Ford Explorer 25000
32000
25000
----------------------------------------------------
Total Explorer 82000
----------------------------------------------------
Total Ford 82000


Basically I would like to print subtotals. I have achieved the
grouping of rows in the ItemDataBoundEvent... When I add a new
DataGridItem to contain the group totals, the whole output gets messed
up which leads me to think that I cannot create a new Item on
ItemDataBound event.

Can you guys give me any pointers to information that might be of
help. I would like to do this in one of the instrinic Datagrid events
(ItemDataBound or ItemCreated) and avoid the rollup operator or
changes to the underlying datatable as much as possible.

Thanks in advance
 
A

Alvin Bruney [MVP]

you wouldn't need to add a new item.
in your itemdatabound event, you would find the row in question and remove
all the columns in the row except one. Then you take that one remaining
column and use its row span property to stretch it across the empty columns.
You can fill text in there and right justify or customize it however you see
fit. You would need to do that for the very next row and enter ----- to
create the subtotal line. proceed in this manner until you have what you
want.
 

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
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top