Getting "Input string was not in a correct format"

Posted on 2006-05-16
Last Modified: 2010-05-18
I just set up a GridView control on a new page, got the <columns> set up the way I need, and when I tried to "Edit" and "Update", I got the error message above.

I couldn't tell which field was causing the error, so I cut them all out of the control, except for a few text fields that already had values, and started adding them back one at a time to see which was the problem field.

The fields I added back were of assorted data types (text, date, currency, yes/no), and the page was working fine after each restored field.

But finally, when I added back a field that was just a straight number, I got the error.

And when I took that column back out, I STILL got the error!

Any ideas what the problem is?


Question by:mlagrange
    LVL 20

    Expert Comment

    please can you post your GridView script please. Oh and how do you bind the data, using the code behind or using the SQL Data Source?

    If you used data Reader, then you might have used GetString() for all. Is this the case?
    LVL 19

    Accepted Solution

    Can you find out what the value is that is passed back? You might be passing back a decimal in a format that is not recognized by the datagrid.

    I'd check there first.


    Author Comment

    Thanks, DreamMaster - when I looked back at the field type in the database, it was different than what I thought it was.

    LVL 19

    Expert Comment

    You are very welcome indeed.

    Glad to have been helpfull,


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    755 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

    18 Experts available now in Live!

    Get 1:1 Help Now