I am trying to add a DataFormatString to a GridCalculatedColumn in my Grid. I have a column Quantity
<telerik:GridNumericColumn SortExpression="Quantity"
DataType="System.Decimal" HeaderText="Quantity"
DataField="Quantity" UniqueName="Quantity"
DataFormatString="{0:F3}" Visible="true">
<ItemStyle HorizontalAlign="Right" />
</telerik:GridNumericColumn>
a column Unit_Price
<telerik:GridNumericColumn SortExpression="Unit_price"
DataType="System.Decimal" HeaderText="Unit price"
DataField="Unit_price" UniqueName="Unit_price"
DataFormatString="{0:C}" Visible="true">
<ItemStyle HorizontalAlign="Right" />
</telerik:GridNumericColumn>
and a column Total
<telerik:GridCalculatedColumn HeaderText="Total" UniqueName="Total"
DataType="System.Double"
DataFields="Quantity, Unit_price" Expression="{0}*{1}"
DataFormatString="{0:C}">
<ItemStyle HorizontalAlign="Right" Width="80px"></ItemStyle>
</telerik:GridCalculatedColumn>
When i run the project i have the following result::
Item Quantity Unit price total
1 7.000 17.95 $ 125,65000000
2 11.000 5.00 $ 55.00000000
Is it possible to have this instead:
Item Quantity Unit price Total
1 7.000 17.95 $ 125,65 $
2 11.000 5.00 $ 55.00 $
Thanks
16 Answers, 1 is accepted
I notice you already implemented a similar code in the first column:
DataFormatString="{0:F3}" |
The same approach could be used to achieve the desired currency format:
DataFormatString="{0:C2}" |
More information concerning this subject can be found here:
BoundField.DataFormatString Property
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I tried it, but it does not work. I don't know if it's because it's a GridCalculatedColumn.
I am using the DatatFormatString="{0:C}" for the column Unite_price and i didn't put a 2 after the C to have 2 digits and a $.
Thanks
I attached a simple example illustrating the needed approach:
Please note that:
{0:C} is default (it depends on your regional settings)
{0:C3} is custom - we specified a fixed-point currency value with three decimal places
All the best,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I don't know why, it's still not working even if i put the DataFormatString="{0:C2}".
I don't know if it's is because it's in a detail grid but i still have the same mistake.
Item Quantity Unite price Total
1 7.000 17.95 $ 125.65000000
2 11.000 5.00 $ 55.00000000
Could you please send us a simple working project illustrating the mentioned behavior via regular support ticket?
Thus we can examine your code locally and then give you the appropriate answer.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I have the same issue. But I have the decimals correct.
I just don't have the $ sign to my "sous total" column but I can see it with my "prix" column.
Here are my columns.
<telerik:GridNumericColumn SortExpression="QUANTITE"
DataType="System.Decimal" HeaderText="QUANTITE"
DataField="QUANTITE" UniqueName="QUANTITE"
DataFormatString="{0:N0}" Visible="true">
<ItemStyle HorizontalAlign="Right" />
</telerik:GridNumericColumn>
<telerik:GridNumericColumn SortExpression="PRIX"
DataType="System.decimal" HeaderText="PRIX"
DataField="PRIX" UniqueName="PRIX"
DataFormatString="{0:C}" Visible="true">
<ItemStyle HorizontalAlign="Right" />
</telerik:GridNumericColumn>
<telerik:GridCalculatedColumn HeaderText="Sous Total" UniqueName="SousTotal"
DataType="System.decimal"
DataFields="QUANTITE, PRIX" Expression="{1}*{0}"
DataFormatString="{0:C2}">
<ItemStyle HorizontalAlign="Right" Width="80px"></ItemStyle>
</telerik:GridCalculatedColumn>
Please try HtmlEncode="false" setting for your columns.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

But unfortunetly it doesn't work as I got the error message:
"Le type 'Telerik.Web.UI.GridCalculatedColumn' ne possède pas de propriété publique appelée 'HtmlEncode'."
Which mean that GridCalculatedColumn doesn't have a property called HtmlEncode.
Any other ideas?
Excuse me but I accidentaly forgot to mention that the referenced feature will be implemented for the next Service Pack release which is expected at the end of this month.
In the meantime you can test the latest unofficial build attached to the thread.
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I took a look at what you sent me.
Sorry but would you like that I install that instead my telerik or it's just to see if it's gonna work for me when your gonna make available the next service pack?
About this service pack, it will be available at the end of september right?
Thanks a lot
Thank you for the interest in RadControls for ASP.NET AJAX.
The features and fixes available in the unofficial build will be part of the upcoming service pack.
As I mentioned before it is expected until the end of the September. Check our website frequently in order to keep yourself informed.
Best regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I would like to know how to install it in my project to make this work
Thanks in advance
How to update our controls to another version or license you can learn from the following knowledge base article on our site:
http://www.telerik.com/support/kb/article/b454K-kad-b454T-a-b454c-a.aspx
Best regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Thanks for the answer.
I tried it but I get the error "TPSResult is not a column that exist" or something like that.
How can I know which version of telerik I am using in my project (just to know if I'm ok)
Thank you

<telerik:GridCalculatedColumn HeaderText="Total" UniqueName="Total"
DataType="System.Double"
DataFields="Quantity, Unit_price" Expression="{0}*{1}"
DataFormatString="{0:C}">
<ItemStyle HorizontalAlign="Right" Width="80px"></ItemStyle>
</telerik:GridCalculatedColumn>
to:
<telerik:GridCalculatedColumn HeaderText="Total" UniqueName="Total"
DataType="System.Decimal"
DataFields="Quantity, Unit_price" Expression="{0}*{1}"
DataFormatString="{0:C}">
<ItemStyle HorizontalAlign="Right" Width="80px"></ItemStyle>
</telerik:GridCalculatedColumn>

Thank you for your reply
That's what I've done and this is working. Sorry that I didn't come to tell the answer before.