?
Solved

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

Posted on 2008-10-02
3
Medium Priority
?
1,477 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Assisted Solution

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

Assisted Solution

by:prairiedog
prairiedog earned 1000 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 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