DotNet Asp: Totals in footer (double up on sort)

  • hansiman / 206 / Thurs, 30 Apr 2009 01:28:00 GMT / Comments (0)
  • Following Scott Mitchell's tutorial "Computing the Sum of a Column"
    http://aspnet.4guysfromrolla.com/demos/dgExample28.aspx the value of
    my summed columns are x2 (double up) upon first column sort command
    (but remains at x2 on next column sorts)?

    really strange!

    Dim HR2_sum As Decimal = 0
    Dim HR5_sum As Decimal = 0
    Dim HR6_sum As Decimal = 0

    Sub dg_ItemDataBound(ByVal sender As Object,
    ByVal e As DataGridItemEventArgs)

    If e.Item.ItemType = ListItemType.Item Or _
    e.Item.ItemType = ListItemType.AlternatingItem Then

    If Not IsDBNull(DataBinder.Eval(e.Item.DataItem, "HR2")) Then
    Dim dHR2 As Decimal =
    Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "HR2"))
    HR2_sum += dHR2
    End If
    If Not IsDBNull(DataBinder.Eval(e.Item.DataItem, "HR5")) Then
    Dim dHR5 As Decimal =
    Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "HR5"))
    HR5_sum += dHR5
    End If
    If Not IsDBNull(DataBinder.Eval(e.Item.DataItem, "HR6")) Then
    Dim dHR6 As Decimal =
    Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "HR6"))
    HR6_sum += dHR6
    End If

    ElseIf e.Item.ItemType = ListItemType.Footer Then

    e.Item.Cells(1).Text = "Totaler"
    e.Item.Cells(2).Text = ""
    e.Item.Cells(3).Text = ""
    e.Item.Cells(4).Text = ""
    e.Item.Cells(5).Text = ""
    e.Item.Cells(6).Text = HR2_sum
    e.Item.Cells(7).Text = HR5_sum
    e.Item.Cells(8).Text = HR6_sum

    End If

    End Sub

  • Keywords:

    dotnet, asp, totals, footer, double, sort, .net

  • http://www.itags.org/dotnet/168796/«« Prior Post - Next Post »»
    • DotNet Asp Questions

      • Totals...

        I've been working on this checkbook thing fer a bit, and well now I'm stuck...i can't seem to grasp ...

        By tech_andrew

      • Touch Panel

        Does anyone have any information on developing a web based touch panel application?Thanks...

        By alexanderhanna

      • Touch Screen - Selected Textbox

        I'm making a touch screen application in asp.net and of course a touch screen application needs a ke...

        By qbikaris

      • Trace dumping

        I need a way to dump the trace info that's displayed on a page when you have tracing enabled. I know...

        By xtorted

      • Totals row in datagridview

        Hi,Iam using the datagridview of .net 2005...i want to implement a totals row at the bottom of the g...

        By acecoder, 1 Comments

      • Totals of rows and columns

        I'm working with .net 2.0.I've been searching how to get a total on a gridview on the rows but also ...

        By damiaan, 2 Comments

      • Totaly noobish GUI question

        Hi there! I searched my C# inside-out for one component - the one they used in outlook, which looks ...

        By therearenomorefreenicks, 2 Comments

      • Touch Screen

        I am working on a web application which will use touch scheen. I am using the button control for in...

        By alexanderhanna, 1 Comments

      • Touch Screen?

        Hello, how can I make a asp.net site work with a touchscreen? do I have to use special components? o...

        By onishirox, 6 Comments