Is there a built in FormatString or a way to use a custom FormatString to take:
$150.00
$1,170.00
$12,170.00
$90.00
$38.00
$750.00
是否有构建在格式字符串中的格式字符串或使用自定义格式字符串的方式:$150.00 $1,170.00 $12,170.00 $90.00 $38.00 $750.00
And format them like:
和格式如:
$ 150.00 $ 1,170.00 $ 12,170.00 $ 90.00 $ 38.00 $ 750.00
without knowing the largest value? This is in a gridview boundcolumn I am currently in the codebehind on rowdatabound looping through the existing rows to get the largest and changing the current one if necessary or changing the existing ones if the current one is the largest, so I have a workaround but was hoping for a clean solution.
不知道最大的值?这是在显示数据表格boundcolumn我目前在rowdatabound后台代码遍历现有行最大的和在必要时改变当前或改变现有如果当前是最大的,所以我有一个解决方法,但希望清洁解决方案。
2 个解决方案
#1
3
If you have the numbers, and the currency will be the same, why not just use a template column in your grid, have a span floated left with the currency and a span floated right with the amount. Could save a lot of hassle...
如果您有这些数字,并且货币将是相同的,为什么不在网格中使用模板列,让一个以货币为左浮动的span和一个以金额为右浮动的span。可以省去很多麻烦……
#2
1
To the best of my knowledge, there is no way to pad a string with spaces without knowing the maximum length and to get the maximum length you would need to know the maximum value.
就我所知,没有办法在不知道最大长度的情况下用空格填充字符串,也没有办法得到所需的最大长度。
Have you considered the use of an alignment property on the column? You would get the following, which is not quite exactly what you are looking for.
您考虑过在列上使用对齐属性吗?你会得到下面的,这不是你想要的。
$150.00
$1,170.00
$12,170.00
$90.00
$38.00
$750.00
#1
3
If you have the numbers, and the currency will be the same, why not just use a template column in your grid, have a span floated left with the currency and a span floated right with the amount. Could save a lot of hassle...
如果您有这些数字,并且货币将是相同的,为什么不在网格中使用模板列,让一个以货币为左浮动的span和一个以金额为右浮动的span。可以省去很多麻烦……
#2
1
To the best of my knowledge, there is no way to pad a string with spaces without knowing the maximum length and to get the maximum length you would need to know the maximum value.
就我所知,没有办法在不知道最大长度的情况下用空格填充字符串,也没有办法得到所需的最大长度。
Have you considered the use of an alignment property on the column? You would get the following, which is not quite exactly what you are looking for.
您考虑过在列上使用对齐属性吗?你会得到下面的,这不是你想要的。
$150.00
$1,170.00
$12,170.00
$90.00
$38.00
$750.00