473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.StringToNumber(String
str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull for UpdateParameter, no
success.

How do I enter null values in FormView ?
Nov 19 '05 #1
8 6144
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.StringToNumber(String
str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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.StringToNumber(String
str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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.StringToNumber(String
str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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.StringToNumber(String
str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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.StringToNumber(String
str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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.StringToNumber(String
str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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.StringToNumber(String
> str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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.FormatException, 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 ConvertEmptyStringToNull
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_ItemUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles
FormView1.ItemUpdating

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

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

' Loop through SqlDataSource UpdateParameters and look for columns
that have null issue
' Use the ConvertEmptyStringToNull property to determine if column
should require this fix
' coupled with data type
For Each upd In SQLData.UpdateParameters
' 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.Decimal, TypeCode.Double, TypeCode.Single
If upd.ConvertEmptyStringToNull = True And
(upd.Direction = Data.ParameterDirection.Input Or upd.Direction =
Data.ParameterDirection.InputOutput) 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.StringToNumber(String
> > str, NumberStyles options, NumberBuffer& number, NumberFormatInfo 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 ConvertEmptyStringToNull 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
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...
0
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...
0
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...
0
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...
0
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...
1
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)....
3
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"...
1
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.