Format Double Values using BoundColumn.DataFormatString

P

Prasad Dannani

Hi,

I have a Double Value. i am planning to display it in "0.0000" format i.e.
the decimals length is fixed i.e. 4.

I am using math.round function which is reducing the length to 4. but if the
length is just 2 digits then it is giving 2 digits only. where i want 4
digits.

Can anyone help me out. I done this functionality in visual basic but now i
want it for c#.net

Thanks in advance
Prasad Dannani
 
P

Peter van der Goes

Prasad Dannani said:
Hi,

I have a Double Value. i am planning to display it in "0.0000" format i.e.
the decimals length is fixed i.e. 4.

I am using math.round function which is reducing the length to 4. but if
the
length is just 2 digits then it is giving 2 digits only. where i want 4
digits.

Can anyone help me out. I done this functionality in visual basic but now
i
want it for c#.net

Thanks in advance
Prasad Dannani
If you are using Visual Studio, search your MSDN help for "BoundColumn".
You'll find articles/examples in C# that illustrate use of the
DataFormalString property.
Or, on the web:

http://msdn.microsoft.com/library/d...rolsboundcolumnclassdataformatstringtopic.asp

The following excerpt may be helpful:

Use the DataFormatString property to provide a custom format for the items
in the column.

The data format string consists of two parts, separated by a colon, in the
form { A: Bxx }. For example, the formatting string {0:F2} displays a
fixed-point number with two decimal places.

Note The entire string must be enclosed in braces to indicate that it is
a format string and not a literal string. Any text outside the braces is
displayed as literal text.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top