Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hello

In my grid view the amount format is like 2000.0000

how can i make it 2 digit decimal point like 2000.00

is there any format.


Thanks.
Posted
Updated 23-Sep-19 19:18pm

XML
<asp:TemplateColumn HeaderText="Rate">
                                       <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                       <ItemStyle HorizontalAlign="Right" />
                                       <ItemTemplate>
                                           <asp:Label ID="uxRatelb" runat="server" CssClass="CaptionLabel" Text='<%#"&nbsp;"+Eval("ChgRate")!=null?String.Format("{0:0.00}",Eval("ChgRate")):""%>'></asp:Label>
                                       </ItemTemplate>
 
Share this answer
 
Hi,

Example:

XML
<td align="left">
 <asp:Label ID="lblRate" runat="server" Text='<%# Eval("ChgRate","{0:N2}") %>' />
</td>


Please vote if help so that others may consider as an answer...
 
Share this answer
 
Comments
zyck 15-Feb-12 1:56am    
great answer!
Set that attribute in the grid view column filed
DataFormatString="{0:0.00}"
 
Share this answer
 
v2
Dear Friend,

Use the
Math.Round()
for doing it.

http://msdn.microsoft.com/en-us/library/75ks3aby.aspx[^]

This link will help you out.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900