Doreen Doreen - 1 year ago 116
ASP.NET (C#) Question

Debugger is not indicating where the source is of error "Input string is not in the correct format"

I know what the error means - I know how to fix it...but I cannot find where it is happening in my code. I suspect it is occurring in dropdownlists that use sqldatasource. I am using VS 2008 with FormView. When I click FV Update button the _ItemUpdating event runs...I have debugged every line of code in that routine and no errors are thrown. I even have a try/catch to find FormatException and SqlException errors and they are not caught. When the page refreshes (after update completes) "Input string error..." pops up with no indication of where in the code or what objects are having the problem. Before I post my code and because I think this is a debugger problem I wanted to ask the question (which I have not found by googling..) :

Is there a VS debugger configuration setting that might solve this problem?

UPDATE: I posted an answer. The problem was that debugger doesn't (at least in my VS 2008 configuration) debug controls on the .aspx page, only the .aspx.cs pages. I literally had to guess where the error was coming from and it took days.

Answer Source

The problem was with a couple of textbox controls on the aspx page that were bound to sqldatasource. Apparently my debugger doesn't debug sqldatasource. I had incorrectly formatted the SQL decimal data types as currency like this:

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

After removing the currency formatting like so: Text='<%# Bind("AirfareCost" ) %>' the Update button started working again!

I noticed my error as I re-wrote the code to fill formview using DataTable and update sql database directly without using sqldatasource.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download