Programming for Everybody: How to sum gridview column values dynamically in vb.net?

How to sum gridview column values dynamically in vb.net?

Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
        Dim Volume As Decimal = 0
        For Each r As GridViewRow In GridView1.Rows
            If r.RowType = DataControlRowType.DataRow Then
                Volume += Convert.ToDecimal(r.Cells(1).Text)
            End If
        Next
        total1.Text = Math.Round(Volume, 0).ToString()
    End Sub

No comments:

Post a Comment