Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Total Sum Value of columns as header row by ID in gridview

Total Sum Value of columns as header row by ID in gridview

Scheduled Pinned Locked Moved C#
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vanillaET
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • V vanillaET

      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

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #2

      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.

      V 1 Reply Last reply
      0
      • N Nagy Vilmos

        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.

        V Offline
        V Offline
        vanillaET
        wrote on last edited by
        #3

        Can u give me solution? I need to accomplish it. Thanks.

        N 1 Reply Last reply
        0
        • V vanillaET

          Can u give me solution? I need to accomplish it. Thanks.

          N Offline
          N Offline
          Nagy Vilmos
          wrote on last edited by
          #4

          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.

          V 1 Reply Last reply
          0
          • N Nagy Vilmos

            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.

            V Offline
            V Offline
            vanillaET
            wrote on last edited by
            #5

            Thanks for your help. I'm now trying to write my program according to your psudo code. At first, I thought this program in a very confused way. Thanks a lot! :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups