Subtotals in Gridview

Discussion in 'Microsoft ASP .NET' started by Hutty, Jul 22, 2008.

  1. Hutty

    Hutty Guest

    I have searched the net but have been unable to find a solution to
    subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
    where I would like to subtotal rows throughout the gridview based on column
    value "Type". I am using VB.NET. Thanks.
    --
    Hutty
     
    Hutty, Jul 22, 2008
    #1
    1. Advertisements

  2. The way to do this sort of things is to use a repeater or a listview with
    ItemTemplate made out of two html table rows. The first <tr> will be used as
    a regular row. The second <tr> will contain subtotals. It will be hidden for
    all items (rows) but the last item for each Type. You will need to handle
    either ItemDataBound or PreRender event to calculate the subtotals, detect
    the last item for every Type and show the subtotal <tr> for the detected
    last items.

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Hutty" <> wrote in message
    news:...
    >I have searched the net but have been unable to find a solution to
    > subtotaling in a gridview. I have a gridview that is bounded to
    > sqldatasource
    > where I would like to subtotal rows throughout the gridview based on
    > column
    > value "Type". I am using VB.NET. Thanks.
    > --
    > Hutty
     
    Eliyahu Goldin, Jul 23, 2008
    #2
    1. Advertisements

  3. Hutty

    Hutty Guest

    I failed to mention I am using a nested gridview in application. The second
    gridview shows the details of the master gridview where I want to display
    totals. My goal is to show hierarchial data with subtotals at major
    intervals. Will the repeater accomplish this task? Thanks.
    --
    Hutty


    "Eliyahu Goldin" wrote:

    > The way to do this sort of things is to use a repeater or a listview with
    > ItemTemplate made out of two html table rows. The first <tr> will be used as
    > a regular row. The second <tr> will contain subtotals. It will be hidden for
    > all items (rows) but the last item for each Type. You will need to handle
    > either ItemDataBound or PreRender event to calculate the subtotals, detect
    > the last item for every Type and show the subtotal <tr> for the detected
    > last items.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Hutty" <> wrote in message
    > news:...
    > >I have searched the net but have been unable to find a solution to
    > > subtotaling in a gridview. I have a gridview that is bounded to
    > > sqldatasource
    > > where I would like to subtotal rows throughout the gridview based on
    > > column
    > > value "Type". I am using VB.NET. Thanks.
    > > --
    > > Hutty

    >
    >
    >
     
    Hutty, Jul 23, 2008
    #3
  4. net

    I have searched the net but have been unable to find a solution to
    subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
    where I would like to subtotal rows throughout the gridview based on column
    value "Type".
    I am using VB.NET.

    Regards
    RAJIV



    Hutt wrote:

    Subtotals in Gridview
    22-Jul-08

    I have searched the net but have been unable to find a solution to
    subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
    where I would like to subtotal rows throughout the gridview based on column
    value "Type". I am using VB.NET. Thanks
    --
    Hutty

    Previous Posts In This Thread:

    On Tuesday, July 22, 2008 1:26 PM
    Hutt wrote:

    Subtotals in Gridview
    I have searched the net but have been unable to find a solution to
    subtotaling in a gridview. I have a gridview that is bounded to sqldatasource
    where I would like to subtotal rows throughout the gridview based on column
    value "Type". I am using VB.NET. Thanks
    --
    Hutty

    On Wednesday, July 23, 2008 9:10 AM
    Eliyahu Goldin wrote:

    The way to do this sort of things is to use a repeater or a listview with
    The way to do this sort of things is to use a repeater or a listview with
    ItemTemplate made out of two html table rows. The first <tr> will be used as
    a regular row. The second <tr> will contain subtotals. It will be hidden for
    all items (rows) but the last item for each Type. You will need to handle
    either ItemDataBound or PreRender event to calculate the subtotals, detect
    the last item for every Type and show the subtotal <tr> for the detected
    last items

    --
    Eliyahu Goldin
    Software Develope
    Microsoft MVP [ASP.NET
    http://msmvps.com/blogs/egoldi
    http://usableasp.ne

    "Hutty" <> wrote in message
    news:...

    On Wednesday, July 23, 2008 2:05 PM
    Hutt wrote:

    I failed to mention I am using a nested gridview in application.
    I failed to mention I am using a nested gridview in application. The second
    gridview shows the details of the master gridview where I want to display
    totals. My goal is to show hierarchial data with subtotals at major
    intervals. Will the repeater accomplish this task? Thanks
    --
    Hutt

    "Eliyahu Goldin" wrote:


    Submitted via EggHeadCafe - Software Developer Portal of Choice
    WPF Reflection Effect
    http://www.eggheadcafe.com/tutorial...-beab-49bd76e20b9b/wpf-reflection-effect.aspx
     
    rajiv gandhir, Apr 13, 2010
    #4
  5. Re: net

    "rajiv gandhir" wrote in message news:...
    > I have searched the net but have been unable to find a solution to
    > subtotaling in a gridview. I have a gridview that is bounded to
    > sqldatasource
    > where I would like to subtotal rows throughout the gridview based on
    > column
    > value "Type".
    > I am using VB.NET.


    You have two choices in ASP.NET (actually any .NET)

    1. Filter the results prior to binding. This means calculating subtotals and
    making them a new field before you bind
    2. Intercepting the binding event and adding the subtotals.

    Either will work. I prefer the first if it is every row. And you have two
    choices on that one:

    1. Refactor the query to add subtotal (if per row subtotal is the goal this
    works well)
    2. Refactor the data object to add subtotal

    On the second point, you can add a column to a DataSet (if used) or have the
    object with a subtotal field that is automatically calculated by the "domain
    model" data object.

    If none of this makes sense, you need to google the basics of domain
    modeling or DataSets, and possibly the binding events in the Grid you are
    using.

    --
    Peace and Grace,
    Greg

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    ************************************************
    | Think outside the box! |
    ************************************************
     
    Gregory A. Beamer, Apr 13, 2010
    #5
    1. Advertisements

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

    GridView in a GridView

    Nalaka, Nov 11, 2005, in forum: Microsoft ASP .NET
    Replies:
    6
    Views:
    323
    Nalaka
    Dec 5, 2005
  2. Replies:
    3
    Views:
    681
  3. Carlos Albert

    GridView in a GridView

    Carlos Albert, Dec 5, 2005, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    217
    Carlos Albert
    Dec 6, 2005
  4. Carlos Albert

    Gridview inside Gridview little problems...

    Carlos Albert, Dec 6, 2005, in forum: Microsoft ASP .NET
    Replies:
    1
    Views:
    236
    Carlos Albert
    Dec 6, 2005
  5. Guest

    GridView Hierarchical View - Gridview in Gridview

    Guest, May 9, 2006, in forum: Microsoft ASP .NET
    Replies:
    1
    Views:
    837
    Guest
    May 9, 2006
Loading...

Share This Page