문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top