C1Gridview Footer Totals.

Posted by: jaynarayan on 10 September 2017, 11:31 am EST

  • Posted 10 September 2017, 11:31 am EST

    I need to Sum up a  column "Cost"  and display the total in the footer. I could not find any discussions other than this (legacy grid) http://helpcentral.componentone.com/CS/forums/p/69297/188969.aspx#188969. I tried this but did not work.  any suggestions?


    Dim priceTotal As Decimal = 0



     Private Sub C1GridViewItemsList_RowDataBound(ByVal sender As Object, ByVal e As C1.Web.UI.Controls.C1GridView.C1GridViewRowEventArgs) Handles C1GridViewItemsList.RowDataBound


            If e.Row.RowType = C1GridViewRowType.DataRow Then


                priceTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, _


                  "TotalCost"))


            ElseIf e.Row.RowType = C1GridViewRowType.Footer Then


                e.Row.Cells(0).Text = "Grand Total Cost:"


                e.Row.Cells(1).Text = priceTotal.ToString("c")


            End If


        End Sub


  • Replied 10 September 2017, 11:31 am EST

    Hello,


    Please take a look at the attached sample.  I have this setup with a template and with a standard column.  I think the problem above is that RowDataBound event will not fire for the Footer row unless it bound.  I used the RowCreated event to supply the footer with the total.  Thanks and I hope this helps.


    Regards,


    -Raleigh


    2010/04/231122_WebApplication1.zip
  • Replied 10 September 2017, 11:31 am EST

    Thanks, For some reason I did not get any notification that someone responded for my question! I'll check the sample & try it out. thanks again.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels