I have a gridview in my web app and need to get the sum of one column. The gridview data is all bound by asp:boundfields. Not sure what the best way to do this is because I need the data in decimal format and boundfields are strings.
This is my code; this all happens in the RowDataBound:
Dim row As GridViewRow
Dim i As Integer
Dim cols As Intger = grdName.Columns.Count
Dim intTotal As Decimal = 0.0
Dim DevTotal As Integer = 0
If e.Row.RowType = DataControlRowType.DataRow Then
DevTotal += Convert.Int32(e.Row.Cells(3).Text)
intTotal = Convert.ToDecimal(DevTotal)
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "Totals:"
e.Row.Cells(3).Text = intTotal.ToString
End If
Also tried this method but didn't iterate through the values of the cells,
This is my code; this all happens in the RowDataBound:
Dim row As GridViewRow
Dim i As Integer
Dim cols As Intger = grdName.Columns.Count
Dim intTotal As Decimal = 0.0
Dim DevTotal As Integer = 0
If e.Row.RowType = DataControlRowType.DataRow Then
DevTotal += Convert.Int32(e.Row.Cells(3).Text)
intTotal = Convert.ToDecimal(DevTotal)
ElseIf e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Text = "Totals:"
e.Row.Cells(3).Text = intTotal.ToString
End If
Also tried this method but didn't iterate through the values of the cells,