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

Formatting Currency for 0.00 in RadGrid

6 Answers 4999 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 29 Jan 2009, 05:47 PM
When my data source has a 0.00 in it and I am using dataFormatString="{0:$###,###.##}" in my RadGrid, it is stripping out the zeros and also showing more than two decimal places. Does someone know how to effective show the zeros or alternatively how to use something perhaps besides a GridBoundColumn and still be able to aggregate and filter columns.

 

6 Answers, 1 is accepted

Sort by
0
Steve Y
Top achievements
Rank 2
answered on 29 Jan 2009, 06:00 PM
I'm using a GridNumericColumn and $0.00 displays correctly, filtering works, and I have an aggregate sum in the footer which displays fine too.

Try this:

<telerik:GridNumericColumn DataField="LoanAmount" DataType="System.Decimal" NumericType="Currency"  
      HeaderText="Loan Amount" SortExpression="LoanAmount" UniqueName="LoanAmount"  
      Aggregate="Sum" FooterAggregateFormatString="{0:C}"
</telerik:GridNumericColumn> 

Regards, Steve
0
Daniel
Telerik team
answered on 29 Jan 2009, 06:10 PM
Hello Tina,

Please test the following code:
vb
RadAjaxManager1.Alert(String.Format("{0:$###,##0.00}"CType(0.0, Decimal))) 

c#
RadAjaxManager1.Alert(String.Format("{0:$###,##0.00}", (decimal)0.0)); 

aspx
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" /> 

I hope this helps.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tina
Top achievements
Rank 1
answered on 29 Jan 2009, 06:37 PM
Hey Steve - this works perfectly for everything except bringing in my zeros. The decimal places are now all displaying properly and my data is aggregates as expected.

The column in my table is of data type money. Would that make a difference?

Thanks so much for your help!

Tina
0
Tina
Top achievements
Rank 1
answered on 29 Jan 2009, 06:40 PM

OK - it was a combination of these two answers that actually worked for me:

 

 

<telerik:GridNumericColumn dataFormatString="{0:$###,##0.00}" DataField="BilledAmt" DataType="System.Decimal" NumericType="Currency" HeaderText="BilledAmt" SortExpression="BilledAmt" UniqueName="BilledAmt" Aggregate="Sum" FooterAggregateFormatString="{0:C}">

 

 

 

</telerik:GridNumericColumn>

 

0
Steve Y
Top achievements
Rank 2
answered on 29 Jan 2009, 06:53 PM
My database datatype is also money. I don't need the extra dataFormatString="{0:$###,##0.00}" to have zero in the money field display as $0.00 - it just displays that way. Weird, huh?

btw: doesn't a dataFormatString="{0:C}" work to display $0.00 and always remove leading zeros?

Regards, Steve
0
Daniel
Telerik team
answered on 02 Feb 2009, 05:47 PM
Hello,

You can find more information about the DataFormatString property in MSDN:
BoundColumn..::.DataFormatString Property
Custom Numeric Format Strings

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Tina
Top achievements
Rank 1
Answers by
Steve Y
Top achievements
Rank 2
Daniel
Telerik team
Tina
Top achievements
Rank 1
Share this question
or