Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > "Input string was not in a correct format." Error when returning DataViewRow as a form property

Reply
Thread Tools

"Input string was not in a correct format." Error when returning DataViewRow as a form property

 
 
=?Utf-8?B?Sm9obiBDaG9ybHRvbg==?=
Guest
Posts: n/a
 
      04-14-2004

I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid creating many public properties on the form to do the same thing. At first I tried returning a DataViewRow. This worked fine until I reached the phone field on the parent table and the code

Child form
public DataRowView SelectedAddres

ge

return drvAddress



Parent form
this.txtBTPhone.Text = fAddrSearch.SelectedAddress["Phone"].ToString( )

produced the following error
-----------------------------------------------------------------------------------------------
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dl

Additional information: Input string was not in a correct format
-----------------------------------------------------------------------------------------------

The phone field is a string data type in the dataset on the child table and the actual value of the field was something like "123-456-7890"

At first, I thought this was because the DataRowView wasn't serializing the type information so I thought that I would try using a DataRow from a strongly-typed dataset like this

Child form
public AddressDataset.AddressRow SelectedAddres

ge

return rwAddress



Parent form
this.txtBTPhone.Text = fAddrSearch.SelectedAddress.Phone

This still didn't work - neither did using System.Convert.ToString() or the ToString method of the data row field. I also noticed that null values produced these same results. I tried using the "IsPhoneNull" method of the typed data row but the problem is that the error occurs before method is invoked. It's as if the type is not known and there is no default type converter that will handle these types of data. Something is obviously assuming that the phone number is an integer data type just because the first character is numeric

The only thing that I thought might be causing this is that it might have something to do with the return statement only returning value types. Has anyone else seen this problem? Is it a bug or by design

John Chorlton
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9obiBDaG9ybHRvbg==?=
Guest
Posts: n/a
 
      04-15-2004
OK ...ignore the above post.

For those who want to know, the problem turned out to be due to an assignment to a combo box on the parent form in the statement prior to the phone statement. The value member of the combo box was set to an integer but the SelectedValue that I was assigning was a string - simple. The reason that this threw me off is that the Visual Studio debugger does not break on the combo box assignment line but on the line following the assignment. This still seems strange because it's not consistent with the usual action of the debugger

John
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simulation result is correct but synthesis result is not correct J.Ram VHDL 7 12-03-2008 01:26 PM
ListBox not returning correct SelectedIndex =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?= ASP .Net 1 02-04-2005 03:49 PM
XSLT problem comparing prior sibling, not returning correct value, returns original Phoenix XML 3 12-30-2004 09:51 PM
HttpBrowserCapabilities not returning correct netscape version Earl T ASP .Net 4 10-15-2003 02:34 PM
correct or not correct? Dan HTML 7 10-02-2003 10:16 PM



Advertisments