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") and gridview

Status
Not open for further replies.

mrp9090

Programmer
May 22, 2006
71
GB
I've been working with the gridiview control for a few weeks 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?
 
Have you tried it and looked at what it produced?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
It produces exactly what I would expect ToString() to produce.
 
it can be used for a numeric formatting for decimal places...

Code:
'Produces 1.000 for example, N2 would result in 1.00
checkTbNull(txtIDMM, ds.Tables(0).Rows(0).Item("IDMM"), "N3")

    Sub checkTbNull(ByVal tb As TextBox, ByVal item As Object, ByVal round As String)
        Dim tbVal As Double
        Try
            tbVal = item
            tb.Text = tbVal.ToString(round)
        Catch ex As Exception
            tb.Text = ""
        End Try
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top