Input string was not in a correct format.

Posted on 2009-12-22
Last Modified: 2012-05-08

I'm having an error on my 2.0 application. (please refer to the Server Error details at bottom)
On my website "". When user clicks on tabs below the main image, like New, User, Trucks, Specials. It some times works fine and some times raise following error. These tabs are Anthem:LinkButons which binds specific data on click and update the Anthem:Panel containing that data control.

I've tried to debug and find the problem line in my code but could not get that because as soon the user clicks on a tab it immidiatly goes to this error details page with out even executing the Page_Load event handler.

Any help will be appriciated.


Server Error in '/' Application.

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) +2753299
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
   System.Int32.Parse(String s, IFormatProvider provider) +22
   System.Web.UI.WebControls.ImageButton.LoadPostData(String postDataKey, NameValueCollection postCollection) +192
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +36
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +895
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2547

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
Question by:23-degrees
    LVL 8

    Accepted Solution

    Do the following thing first,
    1) Check all your string variables in the code, this exception comes when your string formats are wrong
    2) have all your code with in try..catch.. throw block
    3) Log the exception into a log file or use Exception handling application block(Enterprise library) to log all exceptions
    4)Publish your website and host it for production.

    Can you post some of your code snippets?

    LVL 7

    Expert Comment

    It works fine, I dont find any err in that..
    LVL 11

    Expert Comment

    Yes i m also not getting any error.
    You can do one thing , you can use .ToString() function wherever is needed for variables. And make sure you are passing string value in string variable parameters and int to int parameters.

    If you know the code line from where u r getting this error and the webservice is on your local machine then you can keep the debug point and debug your code as well.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    This article will show, step by step, how to integrate R code into a R Sweave document
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now