Best Aopproach At Totalling DataGrids

Discussion in 'ASP .Net' started by Mr Newbie, Nov 29, 2005.

  1. Mr Newbie

    Mr Newbie Guest

    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
    Mr Newbie, Nov 29, 2005
    #1
    1. Advertising

  2. 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.




    "Mr Newbie" <> schreef in bericht
    news:...
    > 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
    >
    >
    >
    >
    Edwin Knoppert, Nov 29, 2005
    #2
    1. Advertising

  3. Mr Newbie

    Mr Newbie Guest

    Thanks for your help

    --
    Best Regards

    The Inimitable Mr Newbie º¿º
    "Edwin Knoppert" <> wrote in message
    news:dmidgb$nk3$...
    > 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.
    >
    >
    >
    >
    > "Mr Newbie" <> schreef in bericht
    > news:...
    >> 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
    >>
    >>
    >>
    >>

    >
    >
    Mr Newbie, Nov 29, 2005
    #3
  4. Mr Newbie

    Guest

    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.
    , Nov 29, 2005
    #4
  5. Hmm, prerender might be the best option.
    Afaik it's based on current view/data.



    <> schreef in bericht
    news:...
    >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.
    >
    Edwin Knoppert, Nov 29, 2005
    #5
  6. 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.



    "Edwin Knoppert" <> schreef in bericht
    news:dmidgb$nk3$...
    > 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.
    >
    >
    >
    >
    > "Mr Newbie" <> schreef in bericht
    > news:...
    >> 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
    >>
    >>
    >>
    >>

    >
    >
    Edwin Knoppert, Dec 4, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abul Hasan

    Datagrids

    Abul Hasan, Oct 12, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    535
    Daryll Shatz
    Oct 13, 2003
  2. Tobe

    Client-side Totalling

    Tobe, Jul 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    368
    Ray Dixon [MVP]
    Jul 30, 2003
  3. Debbie Davis

    Grouping totalling maybe an array?

    Debbie Davis, Oct 19, 2004, in forum: ASP General
    Replies:
    6
    Views:
    141
    Debbie Davis
    Oct 20, 2004
  4. John Pritchard-williams

    Most compact command for associate array 'totalling'?

    John Pritchard-williams, Aug 7, 2008, in forum: Ruby
    Replies:
    8
    Views:
    124
    John Pritchard-williams
    Aug 9, 2008
  5. charliefortune

    Simple totalling of a column with onChange()

    charliefortune, Apr 29, 2006, in forum: Javascript
    Replies:
    4
    Views:
    101
    charliefortune
    May 2, 2006
Loading...

Share This Page