views:

20

answers:

0

Hi

In my main window code behind i set the datacontext to an observable collection which is populated with a call to my database. If there are records to be returned everything runs fine. When there are no records i get the error.

There is no source code available for current location and then another window opens with the heading FormatException was unhandled. When i click on view details the innerexception = null and the message = 'the input string was not in the correct format.

When i step through the code it breaks after i set the datacontext: this.DataContext = JobItemsData.

JobItemsData is my observablecollection. I get this error when there is nothing in the collection.

Is there something i need to do to or set so that i can show the main window even if there is nothing to show?

I am also getting this error 'the input string was not in the correct format' when i try to remove an item from the observablecollection:

JobItems jobItem = (JobItems)(LstJobs.SelectedItem); JobItemsData.Remove(jobItem);

above is the line where i get the error, yet if i hit the F11 key it works. I put a try catch block around this code and the app just bombs out with a dialog box to report the error to Microsoft?

Any thoughts?

Thanks Paul