Total Sum Value of columns as header row by ID in gridview
-
The GridView columns are as follow: <Columns> <asp:BoundField HeaderText="ID No." DataField="NRIC" /> <asp:BoundField HeaderText="Name" DataField="LabourName" /> <asp:BoundField HeaderText="Event Name/Duty Roster" DataField="EventName/DutyRoster" /> <asp:BoundField HeaderText="Working Date" DataField="WorkingDate" /> <asp:BoundField HeaderText="Normal(hr)" DataField="NormalHour" /> <asp:BoundField HeaderText="Amt(N)" DataField="NormalRate" /> <asp:BoundField HeaderText="Extra(hr)" DataField="ExtraHour" /> <asp:BoundField HeaderText="Amt(E)" DataField="ExtraRate" /> <asp:BoundField HeaderText="Weekend(hr)" DataField="WeekEndHour" /> <asp:BoundField HeaderText="Amt(W)" DataField="WeekEndRate" /> <asp:BoundField HeaderText="Holiday(hr)" DataField="HolidayHour" /> <asp:BoundField HeaderText="Amt(H)" DataField="HolidayRate" /> <asp:BoundField HeaderText="Allowance" DataField="Allowance" /> &n
-
The GridView columns are as follow: <Columns> <asp:BoundField HeaderText="ID No." DataField="NRIC" /> <asp:BoundField HeaderText="Name" DataField="LabourName" /> <asp:BoundField HeaderText="Event Name/Duty Roster" DataField="EventName/DutyRoster" /> <asp:BoundField HeaderText="Working Date" DataField="WorkingDate" /> <asp:BoundField HeaderText="Normal(hr)" DataField="NormalHour" /> <asp:BoundField HeaderText="Amt(N)" DataField="NormalRate" /> <asp:BoundField HeaderText="Extra(hr)" DataField="ExtraHour" /> <asp:BoundField HeaderText="Amt(E)" DataField="ExtraRate" /> <asp:BoundField HeaderText="Weekend(hr)" DataField="WeekEndHour" /> <asp:BoundField HeaderText="Amt(W)" DataField="WeekEndRate" /> <asp:BoundField HeaderText="Holiday(hr)" DataField="HolidayHour" /> <asp:BoundField HeaderText="Amt(H)" DataField="HolidayRate" /> <asp:BoundField HeaderText="Allowance" DataField="Allowance" /> &n
For the love of God, tag your code so that its pretty:
------------ ------- --------------- ----------------- -------------- -------- --- ------ LabourID Name Event Name Working Date Normal(Hr) Amt(N) ... Total 009 ET All All 5 35.0 ... 95.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Meeting 10 Jul 09 2 20.0 ... 60.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Seminar 13 Jul 09 3 15.0 ... 35.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ 002 Sue All All 6 18.0 ... 40.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Promotion 23 Jul 09 6 18.0 ... 40.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Then we can think about the problem. The solution is not too hard and you needn't have posted 18 billion lines of code.
Panic, Chaos, Destruction. My work here is done.
-
For the love of God, tag your code so that its pretty:
------------ ------- --------------- ----------------- -------------- -------- --- ------ LabourID Name Event Name Working Date Normal(Hr) Amt(N) ... Total 009 ET All All 5 35.0 ... 95.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Meeting 10 Jul 09 2 20.0 ... 60.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Seminar 13 Jul 09 3 15.0 ... 35.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ 002 Sue All All 6 18.0 ... 40.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Promotion 23 Jul 09 6 18.0 ... 40.0 ------------ ------- --------------- ----------------- -------------- -------- --- ------ Then we can think about the problem. The solution is not too hard and you needn't have posted 18 billion lines of code.
Panic, Chaos, Destruction. My work here is done.
-
I can give the solution but you'll learn morew by trying. However I've been told I'm too rude to everyone so, for _Maxx_'s benefit, I will point you gently in the right direction. The problem is complicated by having the summary before the items, but there is an easy way to do this that does not require looping through the items twice. The follwoing psudo code should get you on your way:
/// This is not real code
summary is not set
for each item in the list
if the item key <> summary key
if the summary is set
update the grid entry for summary with the totals
create a new grid entry for summary with item key
set totals to zero
create a new grid entry for item
add item values to totals
if the summary is set
update the grid entry for summary with the totals
Panic, Chaos, Destruction. My work here is done.
-
I can give the solution but you'll learn morew by trying. However I've been told I'm too rude to everyone so, for _Maxx_'s benefit, I will point you gently in the right direction. The problem is complicated by having the summary before the items, but there is an easy way to do this that does not require looping through the items twice. The follwoing psudo code should get you on your way:
/// This is not real code
summary is not set
for each item in the list
if the item key <> summary key
if the summary is set
update the grid entry for summary with the totals
create a new grid entry for summary with item key
set totals to zero
create a new grid entry for item
add item values to totals
if the summary is set
update the grid entry for summary with the totals
Panic, Chaos, Destruction. My work here is done.