pepe
pepe

Reputation: 149

Asp.net Get summary footer in grid view control

I have a grid view control:

 <asp:GridView ID="grdView" runat ="server" AutoGenerateColumns ="false" >                      
     <Columns>                                       
        <asp:BoundField  DataField ="Id" HeaderText ="Agreement ID"/>              
        <asp:BoundField DataField ="Balance" HeaderText ="Balance" />
    </Columns>
</asp:GridView>   

The code behind:

Private Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
    Dim agreementManager As AgreementManager = New AgreementManager()
    Dim lstAgr As List(Of Agreement) = agreementManager.GetAll()
    grdView.DataSource = lstAgr
    grdView.DataBind()
End Sub

The output:

GridViewOutput

Then, I want to add a footer with the summary of balance like this:

enter image description here

Any Idea?

Thanks in advance!!

Upvotes: 0

Views: 1789

Answers (1)

Rajendra
Rajendra

Reputation: 191

You can achieve this, refer this solution :
http://www.c-sharpcorner.com/UploadFile/satyapriyanayak/dsfsdf/

For footer template for each column :

Dim total As Decimal = dt.AsEnumerable().Sum(Function(row) row.Field(Of Decimal)("Balance"))
grdView.FooterRow.Cells(0).Text = "Balance"
grdView.FooterRow.Cells(0).HorizontalAlign = HorizontalAlign.Right
grdView.FooterRow.Cells(1).Text = total.ToString("Balance")

refer this example : ASP.NET gridview footer template

Upvotes: 2

Related Questions