Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.
Become a Premium Member and unlock a new, free course in leading technologies each month.
Dim WorksheetID As Integer
Dim _CRDBTotal As Decimal = 0
Dim _AdjustedTotal As Decimal = 0
Dim _ProposedTotal As Decimal = 0
Dim _ActCostTotal As Decimal = 0
Dim _EstCostTotal As Decimal = 0
Protected Sub GridServices_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridServices.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
_EstCostTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "EstimatedCost"))
_ActCostTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ActualCost"))
_ProposedTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Proposed"))
_AdjustedTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Adjusted"))
_CRDBTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "CreditDebit"))
End If
If Convert.ToInt32(Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "CreditDebit"))) < 0 Then
e.Row.Cells(6).ForeColor = Drawing.Color.Red
End If
If e.Row.RowType = DataControlRowType.Footer Then
' Cell 0
e.Row.Cells(1).Text = "Totals:"
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Right
' Cell 1 - Estimated Total
e.Row.Cells(2).Text = _EstCostTotal.ToString("c")
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Right
' e.Row.Cells(2).CssClass = "pGrandTotal"
' Cell 2 - Actual Total
e.Row.Cells(3).Text = _ActCostTotal.ToString("c")
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right
' e.Row.Cells(3).CssClass = "pGrandTotal"
' Cell 3 - Proposed Total
e.Row.Cells(4).Text = _ProposedTotal.ToString("c")
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(4).ForeColor = Drawing.Color.DarkGreen
' e.Row.Cells(4).CssClass = "pGrandTotal"
' Cell 4 - Adjusted Total
e.Row.Cells(5).Text = _AdjustedTotal.ToString("c")
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
e.Row.Cells(5).ForeColor = Drawing.Color.DarkGreen
' e.Row.Cells(5).CssClass = "pGrandTotal"
' Cell 4 - Credit Debit
e.Row.Cells(6).Text = _CRDBTotal.ToString("c")
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right
' e.Row.Cells(6).CssClass = "pGrandTotal"
If Convert.ToInt32(_CRDBTotal) < 0 Then
e.Row.Cells(6).ForeColor = Drawing.Color.Red
End If
End If
End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.