Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ToString("N2")

Status
Not open for further replies.

mrp9090

Programmer
May 22, 2006
71
GB
I've been working with the gridiview control for a few weekd now, and I saw some code like this :

<ItemTemplate>
<asp:Label ID="lblTarget" Text='<%# GetTarget(decimal.Parse(Eval("Target", "{0:###0.00}").ToString())).ToString("N2") %>' runat="server"></asp:Label>
</ItemTemplate>
<FooterTemplate>
<%# GetTargetTotal().ToString("N2") %>
</FooterTemplate>

What I want to know is, what does ToString("N2") mean? And why is it used?
 
It formats the string to print a decimal to 2 decimal places.
 
Craig,

If so, what would be the point of this line :

GetTarget(decimal.Parse(Eval("Target", "{0:###0.00}").ToString())).ToString("N2")

Surely the {0:###0.00} would do the same job, you don't need both {0:###0.00} and ToString("N2")? Or am I wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top