472,795 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,795 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 6060
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.