I am trying to format my label text
-
28-10-2019 - |
Pergunta
I want my Label
use the {0:c2}
format; however, it doesn't seem to work when I do it the following way:
Client code:
<asp:Label ID="Label4" runat="server" Text="Label" StringFormat="{}{0:c2}"></asp:Label>
Server code (on page load):
Dim dvSql7 As DataView = DirectCast(SqlDataSource7.Select(DataSourceSelectArguments.Empty), DataView)
For Each drvSql7 As DataRowView In dvSql7
Label4.Text = drvSql7("goal").ToString()
Next
What the problem might be? Thanks in advance for any help.
Solução
There is no StringFormat
property of the Label control. What you need to do is format the string before it gets assigned to the Label.Text
property:
Label4.Text = Convert.ToDecimal(drvSql7("goal")).ToString("c")
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow