Reputation: 2729
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.
Upvotes: 3
Views: 8365
Reputation: 4402
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")
Upvotes: 6