C1Gridview Footer Totals.

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

  • Posted 10 September 2017, 11:31 am EST

    <p>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?</p>
    <p>Dim priceTotal As Decimal = 0</p>
    <p> Private Sub C1GridViewItemsList_RowDataBound(ByVal sender As Object, ByVal e As C1.Web.UI.Controls.C1GridView.C1GridViewRowEventArgs) Handles C1GridViewItemsList.RowDataBound</p>
    <p>        If e.Row.RowType = C1GridViewRowType.DataRow Then</p>
    <p>            priceTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, _</p>
    <p>              "TotalCost"))</p>
    <p>        ElseIf e.Row.RowType = C1GridViewRowType.Footer Then</p>
    <p>            e.Row.Cells(0).Text = "Grand Total Cost:"</p>
    <p>            e.Row.Cells(1).Text = priceTotal.ToString("c")</p>
    <p>        End If</p>
    <p>    End Sub</p>
  • Replied 10 September 2017, 11:31 am EST

    <p>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.</p>
  • Replied 10 September 2017, 11:31 am EST

    <p>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.</p>
Need extra support?

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

Learn More

Forum Channels