Solved

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

Posted on 2008-10-02
3
1,468 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

803 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