我正在尝试设置标签文本的格式
我希望我的 Label
使用 {0:c2}
格式;但是,当我按照以下方式执行此操作时,它似乎不起作用:
客户端代码:
<asp:Label ID="Label4" runat="server" Text="Label" StringFormat="{}{0:c2}"></asp:Label>
服务器代码(页面加载时):
Dim dvSql7 As DataView = DirectCast(SqlDataSource7.Select(DataSourceSelectArguments.Empty), DataView)
For Each drvSql7 As DataRowView In dvSql7
Label4.Text = drvSql7("goal").ToString()
Next
问题可能是什么?预先感谢您的任何帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Label 控件没有
StringFormat
属性。您需要做的是在将字符串分配给Label.Text
属性之前格式化字符串:Label4.Text = Convert.ToDecimal(drvSql7("goal")).ToString("c ”)
There is no
StringFormat
property of the Label control. What you need to do is format the string before it gets assigned to theLabel.Text
property:Label4.Text = Convert.ToDecimal(drvSql7("goal")).ToString("c")