the value doesn't actually have a negative in front of it like it does in the database. instead it has Parenthesis around it (to indicate that it's a negative number. So, where my database shows -14323.29, the value in my code behind is (14323.29).
You can try with the below code
Protected Sub gvReport_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvReport.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lookuplblYTDActual As Label = DirectCast(e.Row.FindControl("lblYTDActual"), Label)
ytdActual += Decimal.Parse(Replace(lookuplblYTDActual.Text, "$", ""), System.Globalization.NumberStyles.AllowParentheses Or System.Globalization.NumberStyles.AllowDecimalPoint) '< ----------This Is the line Of code that errors
End If
If e.Row.RowType = DataControlRowType.Footer Then
'Grand Total Section
Dim ftlblYTDActual As Label = DirectCast(e.Row.FindControl("ftlblYTDActual"), Label)
ftlblYTDActual.Text = Decimal.Parse(gtytdActual).ToString("C2")
End If
End Sub
All-Star
50741 Points
9877 Posts
Re: Exception Details: System.FormatException: Input string was not in a correct format.
Sep 05, 2017 02:04 PM|A2H|LINK
You can try with the below code
Aje
My Blog | Dotnet Funda