Showing posts with label Show Value upto Two Decimal Places in Gridview. Show all posts
Showing posts with label Show Value upto Two Decimal Places in Gridview. Show all posts

Tuesday, July 15, 2014

Show Value upto Two Decimal Places in Gridview

Show money or float values upto two decimal places using 
String.Format in Gridview.



<%# String.Format("{0:f2}",DataBinder.Eval(Container.DataItem,"Rate")) %>
or
<asp:label id="Label1" runat="server" text='<%# Eval("Amt","{0:f2}")  %>'></asp:label>
Example :
<asp:templatefield headertext="Rate">
<ItemTemplate>
   <table align="right" style="text-align: right"><tr><td align="right">
    <asp:Label ID="lblRate" runat="server"
Text='<%# String.Format("{0:f2}",DataBinder.Eval(Container.DataItem,"Rate")) %>' ></asp:Label>
   </td></tr></table>
</ItemTemplate>
</asp:templatefield>