I cannot figure this out for the life of me... I have a gridview with a sqldatasource attached and I format the fee_amt in the editItemtemplate <%# Bind("fee_amt","{0:n}") %> like so. When the OnRowUpdating Event is raised via clicking the update lnk button I get this error. Please also note I format the number in the textbox with a "$" like "$200.00".
I am pretty sure the problem is coming from the fee_amt but I may be wrong.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9592843
System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) +146
System.Convert.ToDecimal(String value, IFormatProvider provider) +67
System.String.System.IConvertible.ToDecimal(IFormatProvider provider) +10
System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +491
System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +126
System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean ignoreNullableTypeChanges) +63
System.Web.UI.WebControls.SqlDataSourceView.AddParameters(DbCommand command, ParameterCollection reference, IDictionary parameters, IDictionary exclusionList, String oldValuesParameterFormatString) +550
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +346
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +95
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +1226
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +855
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +121
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +125
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +169
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
Protected Sub OnRowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GridViewDegfaultCharges.RowUpdating
'OnRowUpdating Sets Update Params for the GridView
Dim TextBox2 As TextBox 'category
Dim TextBox3 As TextBox 'fee_name
Dim TextBox4 As TextBox 'fee_amt
Dim CheckBox1 As CheckBox 'inactive
Dim blnValid As Boolean
lblMessage.Text = ""
blnValid = True
TextBox2 = GridViewDegfaultCharges.Rows(e.RowIndex).FindControl("TextBox2")
TextBox3 = GridViewDegfaultCharges.Rows(e.RowIndex).FindControl("TextBox3")
TextBox4 = GridViewDegfaultCharges.Rows(e.RowIndex).FindControl("TextBox4")
CheckBox1 = GridViewDegfaultCharges.Rows(e.RowIndex).FindControl("CheckBox1")
If CheckDefaultChargesCategory(TextBox2.Text) Then
lblMessage.Text = TextBox2.Text & " is not a valid Loan Type"
blnValid = False
e.Cancel = True
Exit Sub
End If
SqlDataDefaultCharges.UpdateParameters("category").DefaultValue = TextBox2.Text
SqlDataDefaultCharges.UpdateParameters("fee_name").DefaultValue = TextBox3.Text
SqlDataDefaultCharges.UpdateParameters("fee_amt").DefaultValue = Convert.ToDecimal(TextBox4.Text).ToString()
SqlDataDefaultCharges.UpdateParameters("investorID").DefaultValue = Convert.ToInt32(_pageID)
SqlDataDefaultCharges.UpdateParameters("inactive").DefaultValue = CheckBox1.Checked
If blnValid Then
SqlDataDefaultCharges.Update()
End If
End Sub