Solved

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

11 Experts available now in Live!

Get 1:1 Help Now