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

Detailsview shows real numbers with commata: Error converting data type nvarchar to real!

P: n/a
Hello,

if have an asp.net web page with a detailsview. This detailsview uses a
sqldatasource connecting to a sql server 2005 database with a select
statement simliar to this one:

SELECT warning_threshold, critical_threshold, weight FROM thresholds
UPDATE thresholds SET warning_threshold=@warning_threshold,
critical_threshold=@critical_threshold, weight =@weight
I also added insert and delete statements to this datasource.

The fields warning_threshold, critical_threshold and weight are of sql-type
real and contain figures between 0.00 and 1.00 (e.g 0.85).

In the gridview those figures are shown with commata (0,85) and if I try to
update the dataset I get thist error:

"Error converting data type nvarchar to real!"

How I can ensure that all real-numbers are shown with a decimal point
instead of a comma?
And how can I asure that the user can enter only decimal points too?

Thank you very much for any advice!

Yours,
Mathias
Sep 9 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mathias,

Formatting is controlled by the cultural settings. If you've set an explicit
UI culture, or indicated an auto culture, or the server's inherient culture
uses a "european" numeric formatting (eg. 999 999,99) then what you are
seeing is the expected behavior.

You could force the culture in the web.config file:
<configuration>
<system.web>
<globalization
requestencoding="utf-8"
responseencoding=" utf-8"
fileencoding=" utf-8"
culture="de-DE"
uiculture="en" />
</system.web>
</configuration>
On a per page basis you can specify the culture:

<%@ Page Culture="ja-JP" UICulture="ja" ResponseEncoding="utf-8"%>

And you can do it with code:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
You can also fish out the name of the current culture:

Thread.CurrentThread.CurrentCulture.EnglishName
Does any of that help?

Regards,

Rob MacFadyen
"Curious Trigger" <Cu*************@nospam.gmx.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hello,

if have an asp.net web page with a detailsview. This detailsview uses a
sqldatasource connecting to a sql server 2005 database with a select
statement simliar to this one:

SELECT warning_threshold, critical_threshold, weight FROM thresholds
UPDATE thresholds SET warning_threshold=@warning_threshold,
critical_threshold=@critical_threshold, weight =@weight
I also added insert and delete statements to this datasource.

The fields warning_threshold, critical_threshold and weight are of
sql-type real and contain figures between 0.00 and 1.00 (e.g 0.85).

In the gridview those figures are shown with commata (0,85) and if I try
to update the dataset I get thist error:

"Error converting data type nvarchar to real!"

How I can ensure that all real-numbers are shown with a decimal point
instead of a comma?
And how can I asure that the user can enter only decimal points too?

Thank you very much for any advice!

Yours,
Mathias

Sep 9 '06 #2

P: n/a
Hi Rob,

thank you very much! I changed my web.config and that solved my problem.
I couldn't simply cut and paste your text, because in web.config you have to
pay attention to lower-case and upper-case letters and leading spaces (e.g.
"utf-8" instead of " utf-8").
So I adopted it like this:

<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
fileEncoding="utf-8"
culture="en-US"
uiCulture="en" />

Regards,
Mathias

"Rob MacFadyen" <rmacfadyen_at_gmail.comschrieb im Newsbeitrag
news:Oc**************@TK2MSFTNGP04.phx.gbl...
Mathias,

Formatting is controlled by the cultural settings. If you've set an
explicit UI culture, or indicated an auto culture, or the server's
inherient culture uses a "european" numeric formatting (eg. 999 999,99)
then what you are seeing is the expected behavior.

You could force the culture in the web.config file:
<configuration>
<system.web>
<globalization
requestencoding="utf-8"
responseencoding=" utf-8"
fileencoding=" utf-8"
culture="de-DE"
uiculture="en" />
</system.web>
</configuration>
On a per page basis you can specify the culture:

<%@ Page Culture="ja-JP" UICulture="ja" ResponseEncoding="utf-8"%>

And you can do it with code:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
You can also fish out the name of the current culture:

Thread.CurrentThread.CurrentCulture.EnglishName
Does any of that help?

Regards,

Rob MacFadyen
"Curious Trigger" <Cu*************@nospam.gmx.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Hello,

if have an asp.net web page with a detailsview. This detailsview uses a
sqldatasource connecting to a sql server 2005 database with a select
statement simliar to this one:

SELECT warning_threshold, critical_threshold, weight FROM thresholds
UPDATE thresholds SET warning_threshold=@warning_threshold,
critical_threshold=@critical_threshold, weight =@weight
I also added insert and delete statements to this datasource.

The fields warning_threshold, critical_threshold and weight are of
sql-type real and contain figures between 0.00 and 1.00 (e.g 0.85).

In the gridview those figures are shown with commata (0,85) and if I try
to update the dataset I get thist error:

"Error converting data type nvarchar to real!"

How I can ensure that all real-numbers are shown with a decimal point
instead of a comma?
And how can I asure that the user can enter only decimal points too?

Thank you very much for any advice!

Yours,
Mathias


Sep 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.