Je suis en train de formater mon texte de l'étiquette
-
28-10-2019 - |
Question
Je veux que mon Label
utiliser le format {0:c2}
; cependant, il ne semble pas fonctionner quand je fais de la manière suivante:
Code client:
<asp:Label ID="Label4" runat="server" Text="Label" StringFormat="{}{0:c2}"></asp:Label>
code du serveur (sur la charge de la page):
Dim dvSql7 As DataView = DirectCast(SqlDataSource7.Select(DataSourceSelectArguments.Empty), DataView)
For Each drvSql7 As DataRowView In dvSql7
Label4.Text = drvSql7("goal").ToString()
Next
Qu'est-ce que le problème pourrait être? Merci à l'avance pour toute aide.
La solution
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")
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow