逗号对绑定的WebForms文本框千位分隔符 [英] Comma for thousands separator on a bound WebForms TextBox

查看:145
本文介绍了逗号对绑定的WebForms文本框千位分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想如下格式的数据绑定值,但我不断收到一个空格作为千​​位分隔符,即所显示的文本始终是12 340.00时,它应该是12,340.00。

我在想什么?

 < ASP:文本框ID =budgetText=服务器文本='<%#绑定(预算,{0:#,0.00}) %>'>< / ASP:文本框>
 

解决方案

尝试指定文化:

 < ASP:文本框
    ID =budgetText
    =服务器
    文字='<%#的String.Format(CultureInfo.InvariantCulture,{0:#,0.00},绑定(预算))%> />
 

全球设置UI文化。

I'm trying to format a data bound value as below, but I keep getting a space as the thousands separator, i.e. the displayed text is always "12 340.00" when it should be "12,340.00".

What am I missing?

<asp:TextBox ID="budgetText" runat="server" Text='<%# Bind("Budget", "{0:#,0.00}") %>'></asp:TextBox>

解决方案

Try specifying the culture:

<asp:TextBox 
    ID="budgetText" 
    runat="server" 
    Text='<%# string.Format(CultureInfo.InvariantCulture, "{0:#,0.00}", Bind("Budget")) %>' />

or set the UI culture globally.

这篇关于逗号对绑定的WebForms文本框千位分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆