Format Double Values using BoundColumn.DataFormatString

  • Thread starter Thread starter Prasad Dannani
  • Start date Start date
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
 
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.
 
Back
Top