This is a migrated thread and some comments may be shown as answers.

Negative Curency value formatting

1 Answer 266 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dipal
Top achievements
Rank 1
Dipal asked on 20 Sep 2012, 06:32 AM
Hi All,

I want to format my "Values" column as shown below format in child/detail grid.  It is a currency value.  I have used GridNumericColumn type and added following properties to this column
DataFormatString="${0:C}" DataType="System.Decimal" NumericType="Currency".

However, it is not formatting currency field for negative values.
 
Example:

 Product Name

Product ID

Values

A

1

$ -12.00 

B

2

$11

C

3

$ - 13

D

4

$ 14

E

5

$ - 16

F

6

$ - 17

 

 

 


so i want all the negative values of coulmn "values" into brackets and without $ sign.
Expected result

 Product Name

Product ID

Values

A

1

$(12.00 )

B

2

$11

C

3

$(13)

D

4

$ 14

E

5

$(16)

F

6

$(17)

 

 

 


1 Answer, 1 is accepted

Sort by
0
Galin
Telerik team
answered on 25 Sep 2012, 08:16 AM
Hi Dipal,

You can achieve this with GridTelplateColumn, e.g.
<telerik:GridTemplateColumn DataField="Number" HeaderText="Number">
    <ItemTemplate>
        <%# customFormat( (int)Eval("Number")  ) %>
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#
protected string customFormat(int number)
{
        return (number).ToString("C" , CultureInfo.GetCultureInfo("en-US"));
}

I hope this helps.



Regards,
Galin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Dipal
Top achievements
Rank 1
Answers by
Galin
Telerik team
Share this question
or