By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,763 Members | 1,609 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,763 IT Pros & Developers. It's quick & easy.

Scientific Notation In Textbox

P: n/a
I am working on an application that requires working with numbers in
scientific notation. I am using SqlServer as the database and I have
created strongly typed data adapters and datasets. The numbers are
defined as numeric in the SqlServer Database and are bound to text
boxes in the app. In the dataset's xml these numbers are defined as
decimal. I am using the binding method Format to display the data in
scientific notation and Parse to convert back to numeric before posting

to the database. This all works just fine until you try to enter
scientific notation into the text box directly. In other words,
entering 1230000000 is OK and parses to 1.23e+009 and is posted to the
DB as 1230000000. But if you try to enter 1.23e+009 into the text box
directly it gets rejected (blanked out) or reverts to the previous
entry.

I have found this to be normal text box behavior when using
strongly typed datasets where you try to enter a value that is invalid
for the data type specified in the dataset. For example, entering an
invalid date into a text box bound to a date column does the same
thing. This behavior is initiated before any validation events have a
chance of firing and seems to be something I cannot control.

So, my question is, can anybody tell me how I can
set up the text boxes to accept direct input of scientific notation so
the users can enter 1.23e9 or 1.23e+9 or 1.23e+009 or 1230000000?

What is most irritating is that in the same app I have datagrids with
datagrid text boxes that accept the same scientific numbers and have no

issue formatting or parsing these numbers without any special handling
or method calls. So in a datagrid text box I can enter 1.23e9, 1.23e+9,

1230000000 and it parses and posts it all just fine. This type of
inconsistant behavior drives me and the users crazy.

Oct 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I didnt read all you wrote but noticed no mention of SqlParameter......look
up SqlParamter and pass in your values as SqlParameters to the db.

Issues with the textbox itself reformatting i am not sure, i would have
thought it would read it as a string and not format at all keeping the '+'
signs? You sure the text box is doing this?
"Greg" <gm*******@tektrekcs.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>I am working on an application that requires working with numbers in
scientific notation. I am using SqlServer as the database and I have
created strongly typed data adapters and datasets. The numbers are
defined as numeric in the SqlServer Database and are bound to text
boxes in the app. In the dataset's xml these numbers are defined as
decimal. I am using the binding method Format to display the data in
scientific notation and Parse to convert back to numeric before posting

to the database. This all works just fine until you try to enter
scientific notation into the text box directly. In other words,
entering 1230000000 is OK and parses to 1.23e+009 and is posted to the
DB as 1230000000. But if you try to enter 1.23e+009 into the text box
directly it gets rejected (blanked out) or reverts to the previous
entry.

I have found this to be normal text box behavior when using
strongly typed datasets where you try to enter a value that is invalid
for the data type specified in the dataset. For example, entering an
invalid date into a text box bound to a date column does the same
thing. This behavior is initiated before any validation events have a
chance of firing and seems to be something I cannot control.

So, my question is, can anybody tell me how I can
set up the text boxes to accept direct input of scientific notation so
the users can enter 1.23e9 or 1.23e+9 or 1.23e+009 or 1230000000?

What is most irritating is that in the same app I have datagrids with
datagrid text boxes that accept the same scientific numbers and have no

issue formatting or parsing these numbers without any special handling
or method calls. So in a datagrid text box I can enter 1.23e9, 1.23e+9,

1230000000 and it parses and posts it all just fine. This type of
inconsistant behavior drives me and the users crazy.

Oct 5 '06 #2

P: n/a
I'm sure. I can use Format and Parse to display the scientific notation
and parse to numeric for the DB. But if I enter scientific notation
directly into the textbox it rejects and and reverts to it's previous
value.

In other words,
entering 1230000000 is OK and parses to 1.23e+009 and is posted to the
DB as 1230000000. But if you try to enter 1.23e+009 into the text box
directly it gets rejected (blanked out) or reverts to the previous
entry.

Daniel wrote:
I didnt read all you wrote but noticed no mention of SqlParameter......look
up SqlParamter and pass in your values as SqlParameters to the db.

Issues with the textbox itself reformatting i am not sure, i would have
thought it would read it as a string and not format at all keeping the '+'
signs? You sure the text box is doing this?
"Greg" <gm*******@tektrekcs.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
I am working on an application that requires working with numbers in
scientific notation. I am using SqlServer as the database and I have
created strongly typed data adapters and datasets. The numbers are
defined as numeric in the SqlServer Database and are bound to text
boxes in the app. In the dataset's xml these numbers are defined as
decimal. I am using the binding method Format to display the data in
scientific notation and Parse to convert back to numeric before posting

to the database. This all works just fine until you try to enter
scientific notation into the text box directly. In other words,
entering 1230000000 is OK and parses to 1.23e+009 and is posted to the
DB as 1230000000. But if you try to enter 1.23e+009 into the text box
directly it gets rejected (blanked out) or reverts to the previous
entry.

I have found this to be normal text box behavior when using
strongly typed datasets where you try to enter a value that is invalid
for the data type specified in the dataset. For example, entering an
invalid date into a text box bound to a date column does the same
thing. This behavior is initiated before any validation events have a
chance of firing and seems to be something I cannot control.

So, my question is, can anybody tell me how I can
set up the text boxes to accept direct input of scientific notation so
the users can enter 1.23e9 or 1.23e+9 or 1.23e+009 or 1230000000?

What is most irritating is that in the same app I have datagrids with
datagrid text boxes that accept the same scientific numbers and have no

issue formatting or parsing these numbers without any special handling
or method calls. So in a datagrid text box I can enter 1.23e9, 1.23e+9,

1230000000 and it parses and posts it all just fine. This type of
inconsistant behavior drives me and the users crazy.
Oct 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.