Solved

Formview "Insert" Input string was not in a correct format

Posted on 2008-10-02
3
1,464 Views
Last Modified: 2013-12-17
I have a formview bound to an objectdatasource and is "linked" to a custom object.  My fields on the form view look like:  <asp:TextBox ID="txtCarNumber" runat="server" Text='<%# Bind("CarNumber") %>' SkinID="txtNumberField" />.

When in "Insert" mode, when the "Insert" link is pressed, I have validation routines that check the values in the TextBoxs.  If the field should be an integer but is empty, I set it to "0".  For example,  I set txtCarNumber.Text = "0" and I let this pass the validation.  

The validation is passed (with no additional postbacks) and the "insert" method continues.  A new instance of my object is created and then the properties are set to the values in the formview.  
   public int CarNumber
    {
        get { return carNumber; }
        set { carNumber = value; }
    }

However, for property "CarNumber' in my object, the "value" is an empty string instead of the "0" I set the txtCarNumber.text to.  This causes an error because "CarNumber" must be an integer value.  

How can I make sure the object is bound to the values in textbox?  Is there away to "re-link" the textbox value to the "Bind()" value without doing a page postback?

0
Comment
Question by:weimha
3 Comments
 
LVL 10

Assisted Solution

by:orbulat
orbulat earned 250 total points
ID: 22632046
just a quick thought
anything relating to "if (!IsPostBack) { xxxx }"  ?
0
 
LVL 22

Assisted Solution

by:prairiedog
prairiedog earned 250 total points
ID: 22634542
>>>If the field should be an integer but is empty, I set it to "0".  
How do you do it? With JavaScript?
0
 

Accepted Solution

by:
weimha earned 0 total points
ID: 22637073
It works when I set it to 0.  I accidently was forgeting about one field and it was causes the problem.  When I set it to 0 it works now.
Thanks,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

14 Experts available now in Live!

Get 1:1 Help Now