469,334 Members | 4,335 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,334 developers. It's quick & easy.

Cannot enter scientific notation into text box bound to strongly typed dataset

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 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. One thing
I tried was setting the causes validation property to false on the text
box. This allows me to enter anything I want but also disables the
Format/Parse methods. 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.

Nov 17 '05 #1
0 1473

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Steve Franks | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.