Looping through all rows and columns (to get sub-totals for each column and row)

Discussion in 'ASP .Net Datagrid Control' started by Ralph Hartman, Aug 24, 2004.

  1. Is there a way to loop through all rows and columns in order to fill a
    sub-totaled columns and a sub-totaled row (footer). I thought about
    doing this through SQL transact but I will be using the rowfilter to
    filter out certain rows and the total number of rows or columns will
    never be constant.

    My datagrid is made up of a district column and a matrix of numbers
    like this.
    [RAW Data Grid]
    District1 1 2 2 3 0
    District2 2 2 1 0 3
    ..
    ..
    ..
    District(N) 4 0 1 0 0
    -----------------------------------------------------

    I would like it to look like this
    [Ending Grid with sub totals for each row and column]
    District1 1 2 2 3 0 8
    District2 2 2 1 0 3 8
    ..
    ..
    ..
    District(N) 4 0 1 0 0 5
    Totals 7 4 4 3 3 21

    Thank you so much in advance for the help.
     
    Ralph Hartman, Aug 24, 2004
    #1
    1. Advertising

  2. Hi,

    You can use the Datagrid 's Event OnDataItemBound.

    This event is fired for each and every Row of the Datagrid.

    Thanks
    Raghavendra
    "Ralph Hartman" <> wrote in message
    news:...
    > Is there a way to loop through all rows and columns in order to fill a
    > sub-totaled columns and a sub-totaled row (footer). I thought about
    > doing this through SQL transact but I will be using the rowfilter to
    > filter out certain rows and the total number of rows or columns will
    > never be constant.
    >
    > My datagrid is made up of a district column and a matrix of numbers
    > like this.
    > [RAW Data Grid]
    > District1 1 2 2 3 0
    > District2 2 2 1 0 3
    > .
    > .
    > .
    > District(N) 4 0 1 0 0
    > -----------------------------------------------------
    >
    > I would like it to look like this
    > [Ending Grid with sub totals for each row and column]
    > District1 1 2 2 3 0 8
    > District2 2 2 1 0 3 8
    > .
    > .
    > .
    > District(N) 4 0 1 0 0 5
    > Totals 7 4 4 3 3 21
    >
    > Thank you so much in advance for the help.
     
    Raghavendra T V, Aug 25, 2004
    #2
    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. helpful sql
    Replies:
    0
    Views:
    830
    helpful sql
    May 19, 2005
  2. =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?=

    Running totals in gridview (when you have many totals required)

    =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?=, Feb 15, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    874
    Alexey Smirnov
    Feb 16, 2007
  3. enggr
    Replies:
    0
    Views:
    1,653
    enggr
    Jun 30, 2010
  4. D
    Replies:
    0
    Views:
    230
  5. Walt Zydhek

    GridView Totals Row as First Row

    Walt Zydhek, Jan 15, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    917
    Alvin Bruney [MVP]
    Jan 17, 2007
Loading...

Share This Page