473,837 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FormView, empty TextBox gives error: Input string was not in a cor

I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
Boolean parseDecimal) +2178925"

This is beacuse some of my TextBoxes are empty (no value). If I enter a
value it is OK.

I need to use Null values to indicate that the field is not fileld in.

I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
success.

How do I enter null values in FormView ?
Nov 19 '05 #1
8 6212
Not quite sure what kind of update you are performing, but if you want to
update a database and want to pass a null value, then in vb.net you can use
the keyword "Nothing" (without quotes).

Regards,

KS

"Ottar" wrote:
I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
Boolean parseDecimal) +2178925"

This is beacuse some of my TextBoxes are empty (no value). If I enter a
value it is OK.

I need to use Null values to indicate that the field is not fileld in.

I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
success.

How do I enter null values in FormView ?

Nov 19 '05 #2
I guess I did not explain my problem well enough :-)

As you know FormView has two-way binding. I use the FormView to view and
edit data in a table. The table contains records with numeric fields that are
null. They render OK, but if I want to update the record I can not have any
empty TextBoxes, because the "automagic" update will fail. I do not write the
update code myself, it is done by the FormView. As you see from the error
message it is conversion from tring to number that fails. this is done
"behind the scenes". If I had handled the update mself I could test for the
problem of course, but FormViw is supposed to do this for you (2 way binding).

Best regards Ottar

"saleek" wrote:
Not quite sure what kind of update you are performing, but if you want to
update a database and want to pass a null value, then in vb.net you can use
the keyword "Nothing" (without quotes).

Regards,

KS

"Ottar" wrote:
I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
Boolean parseDecimal) +2178925"

This is beacuse some of my TextBoxes are empty (no value). If I enter a
value it is OK.

I need to use Null values to indicate that the field is not fileld in.

I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
success.

How do I enter null values in FormView ?

Nov 19 '05 #3


"Ottar" wrote:
I guess I did not explain my problem well enough :-)

As you know FormView has two-way binding. I use the FormView to view and
edit data in a table. The table contains records with numeric fields that are
null. They render OK, but if I want to update the record I can not have any
empty TextBoxes, because the "automagic" update will fail. I do not write the
update code myself, it is done by the FormView. As you see from the error
message it is conversion from tring to number that fails. this is done
"behind the scenes". If I had handled the update mself I could test for the
problem of course, but FormViw is supposed to do this for you (2 way binding).

Best regards Ottar

"saleek" wrote:
Not quite sure what kind of update you are performing, but if you want to
update a database and want to pass a null value, then in vb.net you can use
the keyword "Nothing" (without quotes).

Regards,

KS

"Ottar" wrote:
I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
Boolean parseDecimal) +2178925"

This is beacuse some of my TextBoxes are empty (no value). If I enter a
value it is OK.

I need to use Null values to indicate that the field is not fileld in.

I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
success.

How do I enter null values in FormView ?

Nov 19 '05 #4
I've been searching for two days and have not found a solution either.
Someone please answer this question...

"Ottar" wrote:
I guess I did not explain my problem well enough :-)

As you know FormView has two-way binding. I use the FormView to view and
edit data in a table. The table contains records with numeric fields that are
null. They render OK, but if I want to update the record I can not have any
empty TextBoxes, because the "automagic" update will fail. I do not write the
update code myself, it is done by the FormView. As you see from the error
message it is conversion from tring to number that fails. this is done
"behind the scenes". If I had handled the update mself I could test for the
problem of course, but FormViw is supposed to do this for you (2 way binding).

Best regards Ottar

"saleek" wrote:
Not quite sure what kind of update you are performing, but if you want to
update a database and want to pass a null value, then in vb.net you can use
the keyword "Nothing" (without quotes).

Regards,

KS

"Ottar" wrote:
I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
Boolean parseDecimal) +2178925"

This is beacuse some of my TextBoxes are empty (no value). If I enter a
value it is OK.

I need to use Null values to indicate that the field is not fileld in.

I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
success.

How do I enter null values in FormView ?

Nov 19 '05 #5


"Ottar" wrote:
I guess I did not explain my problem well enough :-)

As you know FormView has two-way binding. I use the FormView to view and
edit data in a table. The table contains records with numeric fields that are
null. They render OK, but if I want to update the record I can not have any
empty TextBoxes, because the "automagic" update will fail. I do not write the
update code myself, it is done by the FormView. As you see from the error
message it is conversion from tring to number that fails. this is done
"behind the scenes". If I had handled the update mself I could test for the
problem of course, but FormViw is supposed to do this for you (2 way binding).

Best regards Ottar

"saleek" wrote:
Not quite sure what kind of update you are performing, but if you want to
update a database and want to pass a null value, then in vb.net you can use
the keyword "Nothing" (without quotes).

Regards,

KS

"Ottar" wrote:
I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
Boolean parseDecimal) +2178925"

This is beacuse some of my TextBoxes are empty (no value). If I enter a
value it is OK.

I need to use Null values to indicate that the field is not fileld in.

I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
success.

How do I enter null values in FormView ?

Nov 19 '05 #6
I've been searching for two days and have not found a solution either.
Someone please answer this question...

"Ottar" wrote:
I guess I did not explain my problem well enough :-)

As you know FormView has two-way binding. I use the FormView to view and
edit data in a table. The table contains records with numeric fields that are
null. They render OK, but if I want to update the record I can not have any
empty TextBoxes, because the "automagic" update will fail. I do not write the
update code myself, it is done by the FormView. As you see from the error
message it is conversion from tring to number that fails. this is done
"behind the scenes". If I had handled the update mself I could test for the
problem of course, but FormViw is supposed to do this for you (2 way binding).

Best regards Ottar

"saleek" wrote:
Not quite sure what kind of update you are performing, but if you want to
update a database and want to pass a null value, then in vb.net you can use
the keyword "Nothing" (without quotes).

Regards,

KS

"Ottar" wrote:
I have a few numeric fields, and when I update i get the error: "Input string
was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
Boolean parseDecimal) +2178925"

This is beacuse some of my TextBoxes are empty (no value). If I enter a
value it is OK.

I need to use Null values to indicate that the field is not fileld in.

I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
success.

How do I enter null values in FormView ?

Nov 19 '05 #7
Did you solve this as I am having the same problem?

"InfoSys" wrote:
I've been searching for two days and have not found a solution either.
Someone please answer this question...

"Ottar" wrote:
I guess I did not explain my problem well enough :-)

As you know FormView has two-way binding. I use the FormView to view and
edit data in a table. The table contains records with numeric fields that are
null. They render OK, but if I want to update the record I can not have any
empty TextBoxes, because the "automagic" update will fail. I do not write the
update code myself, it is done by the FormView. As you see from the error
message it is conversion from tring to number that fails. this is done
"behind the scenes". If I had handled the update mself I could test for the
problem of course, but FormViw is supposed to do this for you (2 way binding).

Best regards Ottar

"saleek" wrote:
Not quite sure what kind of update you are performing, but if you want to
update a database and want to pass a null value, then in vb.net you can use
the keyword "Nothing" (without quotes).

Regards,

KS

"Ottar" wrote:

> I have a few numeric fields, and when I update i get the error: "Input string
> was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
> str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
> Boolean parseDecimal) +2178925"
>
> This is beacuse some of my TextBoxes are empty (no value). If I enter a
> value it is OK.
>
> I need to use Null values to indicate that the field is not fileld in.
>
> I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
> success.
>
> How do I enter null values in FormView ?

Nov 19 '05 #8
Mark,

I did find some information that there was a bug in the clr that causes a
System.FormatEx ception, something to do with converting ToNumber, in any case
the workaround that we are using is to on the Item_Updating event to find the
Values that need to support it to assign them to nothing when they are null.

For example, you can past this little snippet where every this can be an
issue, it assumes you are using a SQLDatasource, just change declaration and
you should be all set. We wrote this as a workaround and are hoping the MS
finds and resolves this issue as we think the ConvertEmptyStr ingToNull
property was put in there specifically for this issue. So we will just
remove it if it is fixed. It tries to make sure that we only override the
proper value, so if it was an output parameter and a different data type it
wouldn't be effected. You can of course just hard code the
e.NewValue(col) .ToString = nothing also.

Good luck,

Protected Sub FormView1_ItemU pdating(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Form ViewUpdateEvent Args) Handles
FormView1.ItemU pdating

Dim Formview As FormView
Dim SQLData As SqlDataSource
Dim upd As Parameter

Formview = CType(sender, FormView)
SQLData = CType(Me.FindCo ntrol(Formview. DataSourceID), SqlDataSource)

' Loop through SqlDataSource UpdateParameter s and look for columns
that have null issue
' Use the ConvertEmptyStr ingToNull property to determine if column
should require this fix
' coupled with data type
For Each upd In SQLData.UpdateP arameters
' If UpdateParameter is an empty string then determine if a
correction should be done

If e.NewValues(upd .Name).ToString = String.Empty Then

Select Case upd.Type
Case TypeCode.Decima l, TypeCode.Double , TypeCode.Single
If upd.ConvertEmpt yStringToNull = True And
(upd.Direction = Data.ParameterD irection.Input Or upd.Direction =
Data.ParameterD irection.InputO utput) Then
e.NewValues(upd .Name) = Nothing
End If
End Select
End If
Next
End Sub

"Mark McDonald" wrote:
Did you solve this as I am having the same problem?

"InfoSys" wrote:
I've been searching for two days and have not found a solution either.
Someone please answer this question...

"Ottar" wrote:
I guess I did not explain my problem well enough :-)

As you know FormView has two-way binding. I use the FormView to view and
edit data in a table. The table contains records with numeric fields that are
null. They render OK, but if I want to update the record I can not have any
empty TextBoxes, because the "automagic" update will fail. I do not write the
update code myself, it is done by the FormView. As you see from the error
message it is conversion from tring to number that fails. this is done
"behind the scenes". If I had handled the update mself I could test for the
problem of course, but FormViw is supposed to do this for you (2 way binding).

Best regards Ottar

"saleek" wrote:

> Not quite sure what kind of update you are performing, but if you want to
> update a database and want to pass a null value, then in vb.net you can use
> the keyword "Nothing" (without quotes).
>
> Regards,
>
> KS
>
> "Ottar" wrote:
>
> > I have a few numeric fields, and when I update i get the error: "Input string
> > was not in a correct format". Next line:" System.Number.S tringToNumber(S tring
> > str, NumberStyles options, NumberBuffer& number, NumberFormatInf o info,
> > Boolean parseDecimal) +2178925"
> >
> > This is beacuse some of my TextBoxes are empty (no value). If I enter a
> > value it is OK.
> >
> > I need to use Null values to indicate that the field is not fileld in.
> >
> > I've tried the property ConvertEmptyStr ingToNull for UpdateParameter , no
> > success.
> >
> > How do I enter null values in FormView ?

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
562
by: Neil Young | last post by:
Hello group, I'm referring to a "rather old thread" (April 21st 2005). Because I also ran into problems with ASP.NET 2.0 formview and DBNull, but found a way around, I would like to share my experiences here. The problem: A given datatable containing nullable datetime or integer column(s) cannot be fed by a formview, if the edited or inserted date string is empty. The same in similarity with other typed columns (not tested). This is...
0
2210
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase .NET 2.0 DataProvider (iAnywhere.Data.AsaClient.dll) into the GAC so it can be used in the ProviderName property of a SQLDataSource and loads properly at run time. The application I'm writing is a bit more complex than the example I'm about to...
0
2183
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1"> <EditItemTemplate>
0
2424
by: Jai | last post by:
Hi, Somebody please tell me how to bind(two way) a checkboxlist with objectdatasource if the checkboxlist is inside a formview..... Code of FormView is like this::--- <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1"> <EditItemTemplate>
0
3591
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
1
6573
by: Pao | last post by:
I have a formview bounded to an objectdatasource. All ok but I have some trouble with a checkbox: when I am in update mode and I update the record, this field is never updated (no errors thrown). The field bounded in the database (MySql) is a string field (ENUM('True','False') default 'False'. The checkbox is correctly bounded in the itemtemplate and in the edititemtemplate.
3
3644
by: J055 | last post by:
Hi I have a PlaceHolder control inside a FormView EditItemTemplate: <asp:PlaceHolder ID="phResponseText" runat="server"> <tr> <td> <asp:Label ID="lblResponseText" runat="server"></asp:Label></td> <td> <asp:TextBox ID="tbResponseText" runat="server" Text='<%#
1
3374
by: Cliff | last post by:
Hi, I expect with this code to see the FormView in the browser but nothing appears (no error, no formview). I checked with variable 'x' and i know there is one record in the dataset. The formview must be editable. Did i forget something? Thanks for help.
8
11976
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property which is not a string, for example a custom type Address which contains properties such as StreetAddress, City, County, Country etc how do i bind to those properties on the same form view? I have tried doing Bind("Address.StreetAddress") but...
0
9852
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10902
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9420
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.