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

How to format value in gridtemplatecolumn

2 Answers 449 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Najah
Top achievements
Rank 1
Najah asked on 24 Dec 2009, 11:46 AM
I want to format data to currency  format on item template. You can see below how I have done it. The only problem is if the user enters 0, it doesn't show anything. Otherwise it correctly shows currency format. I want it to show $0 for zero values.

<telerik:GridTemplateColumn HeaderText="Total Cost" UniqueName="TotalCost" meta:resourcekey="GridTemplateColumnResource7">  
    <ItemTemplate><%# DataBinder.Eval(Container.DataItem, "TotalCost", "{0:$##,###.##}") %> 
        <asp:Label ID="lblTotalCost" runat="server" Text='<%# Eval("TotalCost") %>' Visible="False" meta:resourcekey="lblTotalCostResource1"></asp:Label>                                </ItemTemplate> 
    <EditItemTemplate> 
        <telerik:RadNumericTextBox ID="txtTotalCost" runat="server" EmptyMessage="..." Skin="Office2007" ForeColor="DimGray" Text='<%# DataBinder.Eval(Container, "DataItem.TotalCost") %>' Type="Currency" Width="80px" Culture="English (United States)" ReadOnly="True" Enabled="false" LabelCssClass="radLabelCss_Office2007" MaxValue="999999999" MinValue="-999999999" meta:resourcekey="txtTotalCostResource1" > 
        </telerik:RadNumericTextBox> 
    </EditItemTemplate> 
    <ItemStyle HorizontalAlign="Right" /> 
</telerik:GridTemplateColumn> 

Please help.
Sana Khurram

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 24 Dec 2009, 12:36 PM
Hello Sunny,

Please try to modify the expression this way:
<%# DataBinder.Eval(Container.DataItem, "TotalCost", "{0:$##,##0.0#}")%>

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Najah
Top achievements
Rank 1
answered on 24 Dec 2009, 06:39 PM
No words to thank you for your quick effective reply.

Cheers,
Sana
Tags
Grid
Asked by
Najah
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Najah
Top achievements
Rank 1
Share this question
or