Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Wednesday, 19 September 2012

DevExpress Input string was not in a correct format

I have started using ASP.NET DevExpress controls quite some time now. In last couple of days I have seen a strange error on pages with the following error message :

"Input string was not in a correct format"

Here is what my page consisted of a list of controls
- ASPxTextBox
- ASPxComboBox
- ASPxButton
- ASPxCallback

I want to pass the input data of ASPxTextBox & ASPxComboBox on button click to server via ASPxCallback and store this information in a database. Not so complicated as it sounds.

I have got some Nlog tracing enabled, got try-catch for ASPxCallback and all wired up. Started testing the page and I got this error ""Input string was not in a correct format"

Started debugging. No server side exceptions and nothing wrong, do not know where the error is coming from after googling and search in DevExpress support tickets I have found how to enable callback errors.

So I have enabled tracing callback errors as mentioned by DevExpress in the article Handling Callback Exceptions on Client.

Now I have got the tracing as:-

at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int32.Parse(String s)
at DevExpress.Web.ASPxEditors.ListEditItemsSerializingHelper.ParseItemIndex(String serializedItem, Int32& startPos)
at DevExpress.Web.ASPxEditors.ListBoxItemsSerializingHelper.DeserializeItems(String serializedItems, Boolean sortRequired)
at DevExpress.Web.ASPxEditors.ListBoxProperties.SynchronizeItems(String serializedItems, Boolean isInsertingSyncType)
at DevExpress.Web.ASPxEditors.ASPxComboBox.SynchronizeItems(NameValueCollection postCollection)
at DevExpress.Web.ASPxEditors.ASPxComboBox.LoadPostData(NameValueCollection postCollection)
at DevExpress.Web.ASPxClasses.ASPxWebControl.LoadPostDataInternal(NameValueCollection postCollection, Boolean raisePostDataEvent)

But still do not know where the issue is. So started again looking into code step-by-step and I have found something. The items I am adding to ASPxComboBox is the issue.



var dataItems:
var itemid = 0;
for (var i = 0; i < dataItems.length; i++) {
 var dataItem = dataItems[i];
 if(dataItem[1] == "Available"){
   ClientCmbData.AddItem(dataItem, itemid++);

The issue occurs at ClientCmbData.AddItem(dataItem, itemid++), instead of ClientCmbData.AddItem(dataItem[0], itemid++);

So data passed in for ASPxComboBox items text value is invalid and hence parsing fails. That's it problem solved.

“The computer was born to solve problems that did not exist before.” – Bill Gates


Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers