Link to home
Start Free TrialLog in
Avatar of mnichols1202
mnichols1202

asked on

HELP!!!! System.FormatException: Input string was not in a correct format. in GridView RowUpdating Event



I've tried everything!!!! I have other pages that work fine. This refuses to work!

Here is the RowUpdating Event Code.

        SqlDataSource1.UpdateParameters("REG_ID").DefaultValue = Session("RegID")
        SqlDataSource1.UpdateParameters("CSA_Major_Topic_Category_ID").DefaultValue = 1
        SqlDataSource1.UpdateParameters("CSA_Specialized_Service_Description").DefaultValue = "Mike"
        SqlDataSource1.UpdateParameters("CSA_Distance_Limitation_Applies").DefaultValue = False
        SqlDataSource1.UpdateParameters("CSA_Service_Charge_By_Type_ID").DefaultValue = 1
        SqlDataSource1.UpdateParameters("CSA_Service_Charge_Amount").DefaultValue = 2
        SqlDataSource1.UpdateParameters("CSA_Specialized_Service_Keywords_Entered").DefaultValue = False

(I added the hard values because i know they work.  If i load those into the Stored proc directly they work fine!)


Here the Params from asp:

                    <UpdateParameters>
                        <asp:Parameter Name="ID" Type="Decimal" />
                        <asp:Parameter Name="REG_ID" Type="Decimal" />
                        <asp:Parameter Name="CSA_Major_Topic_Category_ID" Type="Decimal" />
                        <asp:Parameter Name="CSA_Specialized_Service_Description" Type="String" />
                        <asp:Parameter Name="CSA_Distance_Limitation_Applies" Type="Boolean" />
                        <asp:Parameter Name="CSA_Service_Charge_By_Type_ID" Type="Decimal" />
                        <asp:Parameter Name="CSA_Service_Charge_Amount" Type="Decimal" />
                        <asp:Parameter Name="CSA_Specialized_Service_Keywords_Entered" Type="Boolean" />
                    </UpdateParameters>


No matter what i do i get "System.FormatException: Input string was not in a correct format."

The stack trace is useless!!! I'll post if you think it'll help

I'm at a loss as to even figure out how to begin to figure this one out.  I've tried everything i know.
500 points cause this is URGENT! So urgent in fact i'd give 1000 points if i could!
Avatar of ibost
ibost

Generally I get that error when I try to pass something that is not numerical (i.e., a string) into a numeric data type.

I suspect possibly it's the Session("RegID") part is coming back as an object and can't be implicitly cast to a decimal.

Try replacing with a hard coded value and see if it starts working (would narrow down to that parameter) or else try casting Session("RegID") to a decimal value.
Avatar of mnichols1202

ASKER

I had already tried that and same result!
k... post stack trace... maybe there's something there
[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753171
   System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) +119
   System.Decimal.Parse(String s, NumberStyles style, IFormatProvider provider) +37
   System.Convert.ToDecimal(String value, IFormatProvider provider) +50
   System.String.System.IConvertible.ToDecimal(IFormatProvider provider) +10
   System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +495
   System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +264
   System.Web.UI.WebControls.SqlDataSourceView.AddParameters(DbCommand command, ParameterCollection reference, IDictionary parameters, IDictionary exclusionList, String oldValuesParameterFormatString) +557
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +369
   System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +78
   System.Web.UI.WebControls.DetailsView.HandleUpdate(String commandArg, Boolean causesValidation) +1152
   System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +461
   System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
   System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +109
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
Where are you setting this parameter?
<asp:Parameter Name="ID" Type="Decimal" />
It's part of the keynames collection and is bound to a hidden field .

However, i have actually attempted to set the ID parameter with no effect.


I'm wondering if there is a more effective way of debugging this.

Is there a utility or setting i can use to help identify which field the Update is failing on?

ASKER CERTIFIED SOLUTION
Avatar of ibost
ibost

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I noticed that myself...This is my first expierence with bound controls. I usually encode all this myself and in fact use int32.
Maybe i'll try that?

Can you post the code of the stored procedure itself?