Hi Dale,
As Goran suggested, you should first get the strong-typed data object(such
as double or int ....), then performing formatting with the "toString"
function fo the strong-typed data object. Here is the number formatting
reference in .net:
#Standard Numeric Format Strings
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
BTW, you can also use string.Format function to format multiple output
objects.e.g.
===================
double dv = 343.4343;
Console.WriteLine(string.Format("{0:f3}", dv));
=============
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?QnJhc3NpY2FOaWdyYQ==?= <br************@community.nospam>
Subject: Formating numbers
Date: Sun, 8 Jun 2008 09:40:01 -0700
>Greetings,
I am writing an application that prepares a quotation for a customer. The
calculations are done in a SQL Server stored procedure. I use a
datareader
>to fetch the record, but cannot seem to get the data to format correctly.
Since it is a quote I want the data in the format 12.34. Everything seems
fine, except when I have a a zero at the end of the price, then I get
12.3.
>It needs to be 12.30.
When I set the textbox value using the datareader I was using the
ToString()
>function to convert the data from a floating point to a string. Usually
when
>I do this I can apply a format string as an argument (i.e.
ToString("F2")).
>When I use the ToString method of the datareader it does not allow for any
arguments.
Can't seem to find any information about this. I have spent more time
trying to format these prices than I have writing the entire application.
What happened to simple data formatting (like the old sprintf())?
Help!
Dale Hoffman