Add subtotal row to datagrid

Discussion in 'ASP .Net Web Controls' started by Anon, Jan 25, 2005.

  1. Anon

    Anon Guest

    hi,

    i need to subtotal a column in a datagrid and display the result. I have
    come to a point where i can subtotal the columns in the datagrid but cannot
    display the result.

    ex.
    Private Sub dgTimesheet_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    dgTimesheet.ItemDataBound
    If e.Item.Cells(4).Text().GetType Is GetType(System.Double) Then
    subtotal += Double.Parse(e.Item.Cells(4).Text())
    End If
    End Sub

    my question is how do i know when the datagrid has finished binding and then
    add a literal at the bottom of the grid and display the subtotal.

    thanks in advance.
    Anon, Jan 25, 2005
    #1
    1. Advertising

  2. The datagrid doesn't really support adding a subtotal row, but you can fake
    it by overriding the pager row.
    Here are the details:
    http://devcenter.infragistics.com/Articles/ArticleTemplate.Aspx?ArticleID=1229

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Anon" <> wrote in message
    news:...
    > hi,
    >
    > i need to subtotal a column in a datagrid and display the result. I have
    > come to a point where i can subtotal the columns in the datagrid but
    > cannot
    > display the result.
    >
    > ex.
    > Private Sub dgTimesheet_ItemDataBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    > dgTimesheet.ItemDataBound
    > If e.Item.Cells(4).Text().GetType Is GetType(System.Double) Then
    > subtotal += Double.Parse(e.Item.Cells(4).Text())
    > End If
    > End Sub
    >
    > my question is how do i know when the datagrid has finished binding and
    > then
    > add a literal at the bottom of the grid and display the subtotal.
    >
    > thanks in advance.
    >
    Steve C. Orr [MVP, MCSD], Jan 26, 2005
    #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. =?Utf-8?B?U3VyZXNo?=
    Replies:
    1
    Views:
    451
    Saravana
    Nov 22, 2004
  2. Replies:
    0
    Views:
    351
  3. Replies:
    0
    Views:
    406
  4. Ken
    Replies:
    1
    Views:
    1,989
    Teemu Keiski
    Sep 2, 2007
  5. josepm

    Bounded Datagrid and Subtotal rows

    josepm, Mar 29, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    285
    josepm
    Mar 29, 2006
Loading...

Share This Page