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

ItemTemplate DataFormatString

1 Answer 280 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lamees Afify
Top achievements
Rank 1
Lamees Afify asked on 30 Mar 2009, 09:39 PM
hey,
      I have a GridTemplateColumn which has a label inside its ItemTemplate. This label gets bound from a decimal field from the database. I want to make the number that appears in the label to have 1 decimal after the point even if it's a whole number (5 becomes 5.0). How can I do that with the DataFormatString or is there another way?
Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Mar 2009, 05:12 AM
Hi Lamees Afify,

Try the following code for formatting the text of the label to single decimal value.

ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="Quantity"
    <ItemTemplate> 
        <asp:Label runat="server" Text='<%# Bind("Quantity", "{0:N1}") %>' ID="Label1" ></asp:Label>     
    </ItemTemplate> 
</telerik:GridTemplateColumn> 

Thanks,
Shinu.
Tags
Grid
Asked by
Lamees Afify
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or