开发者

I am trying to format my label text

开发者 https://www.devze.com 2023-03-13 00:05 出处:网络
I want my Label use the {0:c2} format; however, it doesn\'t seem to work when I do it the following way:

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("go开发者_运维百科al").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")

0

精彩评论

暂无评论...
验证码 换一张
取 消