Jacksonville Developers User Group

Learn new things...write better code.
Welcome to Jacksonville Developers User Group Sign in | Join | Help
in
Home Blogs Forums

Input String was not in correct format

Last post 10-21-2007, 8:04 PM by Jonathan Bates. 13 replies.
Sort Posts: Previous Next
  •  10-17-2007, 1:42 PM 1900

    • TM2 is not online. Last active: 09-05-2008, 6:24 AM TM2
    • Top 10 Contributor
    • Joined on 08-15-2007
    • Brunswick, Ga
    • Posts 33
    • Points 0

    Super Angry [8o|] Input String was not in correct format

    Does anybody know of a better way to troubleshoot than this?...

    Input string was not in a correct format.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.FormatException: Input string was not in a correct format.

    Source Error:

    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) +2725283
       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.FormView.HandleUpdate(String commandArg, Boolean causesValidation) +1150
       System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +461
       System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
       System.Web.UI.WebControls.LinkButton.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) +174
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    

     

    I have spent all day on this *^*& and still - nothing.  I'm using a FormView control - All of the databinding functionality was written by VWD.  If anyone could help, you would save what few hairs and little sanity I have left..  Let me know what additional info is needed, if any.

    Thanks,

    Weary One

  •  10-17-2007, 1:54 PM 1901 in reply to 1900

    Re: Input String was not in correct format

    Have you identified which line of code is failing, like a int.Parse() call or something?  Does the error always happen or intermittently?

    The Universe has no center and I am it.



    The superior man is modest in his speech, but exceeds in his actions.

  •  10-17-2007, 2:48 PM 1902 in reply to 1901

    • TM2 is not online. Last active: 09-05-2008, 6:24 AM TM2
    • Top 10 Contributor
    • Joined on 08-15-2007
    • Brunswick, Ga
    • Posts 33
    • Points 0

    Re: Input String was not in correct format

    No. I wish.

    Please forgive the lengthy code listing-it's the only way to show what's going on, right?

    I get the error when trying to update.

    <EditItemTemplate>

    <table style="width: 604px">

    <tr>

    <td style="width: 60px; height: 30px" valign="middle">

    Agent</td>

    <td style="width: 3px; height: 30px; text-align: left;" valign="middle">

    <asp:TextBox ID="AgentTextBox" runat="server"

    Text='<%# Bind("Agent") %>'></asp:TextBox>

    &nbsp;

    <asp:TextBox ID="QuoteIDTextBox" runat="server"

    Text='<%# Bind("QuoteID") %>'

    Width="25px">

    </asp:TextBox></td>

    <td style="width: 91px; height: 30px" valign="middle">

    Date Quoted</td>

    <td style="width: 114px; height: 30px"

    valign="middle">

    <asp:TextBox ID="QuoteDateTextBox" runat="server" Text='<%# Bind("QuoteDate", "{0:d}") %>'

    Width="127px"></asp:TextBox>

    </td>

    </tr>

    <tr>

    <td style="width: 60px; height: 30px"

    valign="middle">

    Name</td>

    <td style="width: 3px; height: 30px"

    valign="middle">

    <asp:DropDownList ID="DropDownList1"

    runat="server"

    DataSourceID="sqlClientID"

    DataTextField="ClientName"

    DataValueField="ClientID"

    SelectedValue='<%# Bind("ClientID") %>'

    Width="179px">

    </asp:DropDownList>

    </td>

    <td style="width: 91px; height: 30px"

    valign="middle">

    </td>

    <td style="width: 114px; height: 30px"

    valign="middle">

    </td>

    </tr>

    <tr>

    <td style="width: 60px; height: 30px"

    valign="middle">Location</td>

    <td style="width: 3px; height: 30px;"

    valign="middle">

    <asp:TextBox ID="LocationTextBox"

    runat="server"

    Text='<%# Bind("Location") %>'>

    </asp:TextBox>

    </td>

    <td style="width: 91px; height: 30px"

    valign="middle">

    Subdivision/Condo Assoc&nbsp;</td>

    <td style="width: 114px; height: 30px"

    valign="middle">

    <asp:TextBox ID="ComplexTextBox"

    runat="server"

    Text='<%# Bind("Complex") %>'

    Width="127px">

    </asp:TextBox>

    </td>

    </tr>

    <tr>

    <td style="width: 60px; height: 30px"

    valign="middle">City/State

    </td>

    <td style="width: 3px; height: 30px;"

    valign="middle">

    <asp:TextBox ID="CityTextBox"

    runat="server"

    Text='<%# Bind("City") %>'

    Width="124px">

    </asp:TextBox>,

    <asp:TextBox ID="StateTextBox"

    runat="server"

    Text='<%# Bind("State") %>'

    Width="26px"></asp:TextBox>

    </td>

    <td style="width: 91px; height: 30px"

    valign="middle">

    &nbsp;Building(# or name)</td>

    <td style="width: 114px; height: 30px"

    valign="middle">

    &nbsp;

    <asp:TextBox ID="BuildingTextBox" runat="server"

    Text='<%# Bind("Building") %>'

    Width="123px"></asp:TextBox></td>

    </tr>

    <tr>

    <td style="width: 60px; height: 30px"

    valign="middle">

    &nbsp;Zip</td>

    <td style="width: 3px; height: 30px;"

    valign="middle">

    &nbsp;<asp:TextBox ID="ZipTextBox"

    runat="server"

    Text='<%# Bind("Zip") %>'

    Width="126px">

    </asp:TextBox></td>

    <td style="width: 91px; height: 30px"

    valign="middle">Effective Date

    </td>

    <td style="width: 114px; height: 30px"

    valign="middle">

    <asp:TextBox ID="EffectiveDateTextBox"

    runat="server"

    Text='<%# Bind("EffectiveDate", "{0:d}") %>' Width="127px"></asp:TextBox>

    </td>

    </tr>

    <tr>

    <td style="width: 60px; height: 30px"

    valign="middle">

    County</td>

    <td style="width: 3px; height: 30px;"

    valign="middle">

    <asp:TextBox ID="CountyTextBox"

    runat="server"

    Text='<%# Bind("County") %>'

    Width="147px">

    </asp:TextBox></td>

    <td style="width: 91px; height: 30px"

    valign="middle">Policy #

    </td>

    <td style="width: 114px; height: 30px"

    valign="middle">

    <asp:TextBox ID="PolicyIDTextBox"

    runat="server"

    Text='<%# Bind("PolicyID") %>'

    Width="119px">

    </asp:TextBox>

    </td>

    </tr>

    </table>

    <hr style="width: 527px; height: 3px" />

    <table>

    <tr>

    <td style="width: 229px; height: 30px;"

    valign="middle">Dwelling Limit

    </td>

    <td style="width: 296px; height: 30px;"

    valign="middle">

    <asp:TextBox ID="DwellingLimitTextBox"

    runat="server"

    Text='<%# Bind("DwellingLimit", "{0}") %>'>

    </asp:TextBox>

    </td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    O/S</td>

    <td style="width: 296px; height: 30px;" valign="middle">

    <asp:TextBox ID="OSTextBox" runat="server"

    Text='<%# Bind("OS", "{0}") %>'></asp:TextBox></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Personal Property</td>

    <td style="width: 296px; height: 30px;" valign="middle">

    <asp:TextBox ID="PersPropTextBox" runat="server"

    Text='<%# Bind("PersProp", "{0}") %>'></asp:TextBox></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Loss of Use</td>

    <td style="width: 296px; height: 30px;" valign="middle">

    <asp:TextBox ID="LossUseTextBox" runat="server"

    Text='<%# Bind("LossUse", "{0}") %>'></asp:TextBox></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Liability Limit/Medical Pay<br />

    <font style="font-size:6pt">(Rate Includes $300,000/$1,000)</font></td>

    <td style="width: 296px; height: 30px;" valign="middle">

    <asp:TextBox ID="LiabilityLimitTextBox" runat="server"

    Text='<%# Bind("LiabilityLimit", "{0}") %>'>

    </asp:TextBox>/

    <asp:TextBox ID="MedicalPayTextBox" runat="server"

    Text='<%# Bind("MedicalPay", "{0}") %>'

    Width="113px"></asp:TextBox></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    </td>

    <td style="width: 296px; height: 30px;" valign="middle">

    </td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Year Built&nbsp;

    <asp:TextBox ID="YrBuiltTextBox" runat="server"

    Text='<%# Bind("YrBuilt") %>' Width="92px">

    </asp:TextBox></td>

    <td style="width: 296px; height: 30px;" valign="middle">

    Construction&nbsp;

    <asp:DropDownList ID="DropDownList3"

    runat="server" DataSourceID="sqlConstruction"

    DataTextField="Construction"

    DataValueField="ConstructionID"

    SelectedValue='<%# Bind("ConstructionID") %>'

    Width="150px"></asp:DropDownList></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Residence Type&nbsp;

    <asp:DropDownList ID="DropDownList2"

    runat="server" DataSourceID="sqlResidenceType"

    DataTextField="ResidenceType"

    DataValueField="ResidenceTypeID"

    SelectedValue='<%# Bind("ResidenceTypeID") %>'

    Width="115px"></asp:DropDownList></td>

    <td style="width: 296px; height: 30px;" valign="middle">

    How many weeks&nbsp;

    <asp:TextBox ID="NumWeeksTextBox" runat="server"

    Text='<%# Bind("NumWeeks") %>' Width="74px">

    </asp:TextBox></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Year Updated:</td>

    <td style="width: 296px; height: 30px;" valign="middle">

    </td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Roof&nbsp;

    <asp:TextBox ID="RoofYrTextBox" runat="server"

    Text='<%# Bind("RoofYr") %>'>

    </asp:TextBox></td>

    <td style="width: 296px; height: 30px;" valign="middle">

    Roof Material&nbsp;

    <asp:DropDownList ID="DropDownList4"

    runat="server" DataSourceID="sqlRoof"

    DataTextField="RoofMaterial"

    DataValueField="RoofID"

    SelectedValue='<%# Bind("RoofID") %>'>

    </asp:DropDownList></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    Plumbing&nbsp;

    <asp:TextBox ID="PlumbingTextBox" runat="server"

    Text='<%# Bind("Plumbing") %>'

    Width="120px"></asp:TextBox></td>

    <td style="width: 296px; height: 30px;" valign="middle">

    Electrical&nbsp;

    <asp:TextBox ID="ElectricalTextBox" runat="server"

    Text='<%# Bind("Electrical") %>'>

    </asp:TextBox></td>

    </tr>

    <tr>

    <td style="width: 229px; height: 30px;" valign="middle">

    HVAC&nbsp;

    <asp:TextBox ID="HVACTextBox" runat="server"

    Text='<%# Bind("HVAC") %>'

    Width="125px"></asp:TextBox></td>

    <td style="width: 296px; height: 30px;" valign="middle">

    </td>

    </tr>

    <tr>

    <td colspan="2" style="width: 296px; height: 30px"

    valign="middle" align="left">

    Prior Losses:

    <asp:TextBox ID="PriorLossesTextBox" runat="server"

    Text='<%# Bind("PriorLosses") %>' Width="419px"></asp:TextBox></td>

    </tr>

    </table>

    <hr />

    <table style="width: 530px; height: 84px">

    <tr>

    <td colspan="1">

    Rate

    <asp:TextBox ID="RateTextBox" runat="server"

    Text='<%# Bind("Rate", "{0:F}") %>'

    Width="66px"></asp:TextBox></td>

    <td colspan="3">

    &nbsp; </td>

    <td colspan="2">

    &nbsp;

    </td>

    </tr>

    <tr>

    <td colspan="1">

    </td>

    <td colspan="3">

    Policy Fee</td>

    <td colspan="2">

    &nbsp;

    <asp:TextBox ID="FeeTextBox" runat="server"

    Style="text-align: right"

    Text='<%# Bind("Fee", "{0:C}") %>'

    Width="113px"></asp:TextBox></td>

    </tr>

    <tr>

    <td colspan="1">

    </td>

    <td colspan="3">

    Inspection Fee</td>

    <td colspan="2">

    &nbsp;

    <asp:TextBox ID="InspectionFeeTextBox" runat="server"

    Text='<%# Bind("InspectionFee", "{0:C}") %>'

    Width="113px"></asp:TextBox></td>

    </tr>

    <tr>

    <td colspan="1">

    </td>

    <td colspan="3">

    </td>

    <td colspan="2">

    &nbsp; &nbsp;&nbsp;

    </td>

    </tr>

    <tr>

    <td colspan="1">

    </td>

    <td colspan="3">

    </td>

    <td colspan="2">

    &nbsp;

    </td>

    </tr>

    </table>

    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"

    Text="Update">

    </asp:LinkButton>

    <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"

    Text="Cancel">

    </asp:LinkButton>

    </EditItemTemplate>

     

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"

    SelectCommand="GetQuotes"

    UpdateCommand="UpdateQuote"

    SelectCommandType="StoredProcedure"

    UpdateCommandType="StoredProcedure">

    <SelectParameters>

    <asp:QueryStringParameter Name="QuoteID" QueryStringField="QuoteID" Type="Int32" />

    </SelectParameters>

    <UpdateParameters>

    <asp:Parameter Name="QuoteID" Type="Int32" />

    <asp:Parameter Name="ClientID" Type="Int32" />

    <asp:Parameter Name="QuoteDate" Type="DateTime" />

    <asp:Parameter Name="Location" Type="String" />

    <asp:Parameter Name="Complex" Type="String" />

    <asp:Parameter Name="EffectiveDate" Type="DateTime" />

    <asp:Parameter Name="PolicyID" Type="String" />

    <asp:Parameter Name="City" Type="String" />

    <asp:Parameter Name="State" Type="String" />

    <asp:Parameter Name="County" Type="String" />

    <asp:Parameter Name="Zip" Type="String" />

    <asp:Parameter Name="DwellingLimit" Type="Decimal" />

    <asp:Parameter Name="OS" Type="Decimal" />

    <asp:Parameter Name="PersProp" Type="Decimal" />

    <asp:Parameter Name="LossUse" Type="Decimal" />

    <asp:Parameter Name="LiabilityLimit" Type="Decimal" />

    <asp:Parameter Name="MedicalPay" Type="Decimal" />

    <asp:Parameter Name="YrBuilt" Type="String" />

    <asp:Parameter Name="ResidenceTypeID" Type="Int32" />

    <asp:Parameter Name="NumWeeks" Type="Int16" />

    <asp:Parameter Name="ConstructionID" Type="Int32" />

    <asp:Parameter Name="RoofYr" Type="String" />

    <asp:Parameter Name="RoofID" Type="Int32" />

    <asp:Parameter Name="HVAC" Type="String" />

    <asp:Parameter Name="Plumbing" Type="String" />

    <asp:Parameter Name="Electrical" Type="String" />

    <asp:Parameter Name="Rate" Type="Single" />

    <asp:Parameter Name="PriorLosses" Type="String" />

    <asp:Parameter Name="Fee" Type="Decimal" />

    <asp:Parameter Name="Agent" Type="String" />

    <asp:Parameter Name="InspectionFee" Type="Decimal" />

    <asp:Parameter Name="Building" Type="String" />

    </UpdateParameters>

  •  10-17-2007, 2:59 PM 1903 in reply to 1902

    Re: Input String was not in correct format

    When you update, are you making sure that all of the numeric parameters(QuoteID, ClientID, DwellingLimit OS, PersProp, LossUse, LiabilityLimit, MedicalPay, ResidenceTypeID, NumWeeks, ConstructionID, RoofID, Rate, Fee, InspectionFee) have a numeric value in them?

    The Universe has no center and I am it.



    The superior man is modest in his speech, but exceeds in his actions.

  •  10-17-2007, 3:07 PM 1904 in reply to 1903

    • TM2 is not online. Last active: 09-05-2008, 6:24 AM TM2
    • Top 10 Contributor
    • Joined on 08-15-2007
    • Brunswick, Ga
    • Posts 33
    • Points 0

    Re: Input String was not in correct format

    Yes.

    I have typed numerical values in all of the fields except for:

    QuoteID & ClientID - values do not change

    ResidenceTypeID, ConstructionID, and RoofID-values selected from dropdownlists

     

  •  10-18-2007, 4:21 PM 1910 in reply to 1904

    Re: Input String was not in correct format

    It is possible that the formating on the Rate and Fee text boxes are causing an issue when the page is posted back.


    The Universe has no center and I am it.



    The superior man is modest in his speech, but exceeds in his actions.

  •  10-19-2007, 8:04 AM 1911 in reply to 1910

    • TM2 is not online. Last active: 09-05-2008, 6:24 AM TM2
    • Top 10 Contributor
    • Joined on 08-15-2007
    • Brunswick, Ga
    • Posts 33
    • Points 0

    Re: Input String was not in correct format

    I tried to find the source of the error by commenting various update parameters, but couldn't get the right combo.  Here's the strange thing - when all of the update parameters were commented out, the page works great.  Isn't that odd?  Does the program insert code it doesn't need?  I guess my real question is - Are the <asp:parameters> needed when using stored procedures to select, insert, update, and delete?  Or is that completely irrelevant?

    Coul