可以DataType.Currency DataAnnotation在多货币环境中使用? [英] Can DataType.Currency DataAnnotation be used in a multi currency enviroment?

查看:601
本文介绍了可以DataType.Currency DataAnnotation在多货币环境中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用:

[DataType(DataType.Currency)]
public decimal TotalPrice { get; set; }

我得到一个好看的格式化文本: $ U 4.882,50

现在,如果我在网站上多种货币,让我们说一个产品,我显示$ U和U $ S以外?我知道,数据标注工作与文化的信息,我想我不能在我的情况下使用DataType.Currency还是我失去了一些东西基本在这里?

Now, what if I have multiple currencies on the site, let's say one product I'm showing in $U and other in U$S ? I know that data annotation works with culture information, I guess I can't use DataType.Currency in my situation or am I missing something fundamental here ?

推荐答案

可以使用的货币标注。然而,它仅仅是告诉MVC显示器或编辑模板要使用的。至于你说当前模板使用系统货币。你将不得不提供自定义编辑模板或显示模板和一些其他的方法来确定的货币符号来显示

The currency annotation can be used. However it is just telling MVC which display or editor template to use. As you say current template uses the system currency. You would have to provide custom editor template or display template and some other way to determine the currency symbol to display

这里如何提供自己的实现。

Look here at how to provide your own implementations

这篇关于可以DataType.Currency DataAnnotation在多货币环境中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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