1

我想知道是否会格式化网格视图控件,以在值之前显示英镑符号。在 access 数据库中,有一个货币符号,但是,当将数据库附加到网格视图时,数据显示但没有货币符号。

抱歉,我的问题的描述写得不好。感谢您的时间。

4

4 回答 4

3

Did you try using DataFormatString="{0:C}" on your column?

<asp:BoundField DataField="SomeValue" DataFormatString="{0:C}" />

It will display the currency symbol according to the locale settings.

于 2012-05-02T20:28:29.197 回答
1

As lcarus said, set the DataFormatString to "{0:C}" and it should work. However, and someone correct me if I am wrong, but it'll depend on the culture settings on the server. For example, if the culture setting on the server is "en-US", then you'll see a dollar sign. If I understand your post correctly, you're looking for the Pounds (GBP) symbol.

Now if your server is set for English UK, you're fine. But if its set to English US and you don't have the necessary access to change it, you can use a TemplateField.

<asp:TemplateField HeaderText="MyColumn">
     <ItemTemplate>
          $<%# Eval("MyColumn")%>
     </ItemTemplate>
</asp:TemplateField>

I've used the dollar sign in that example, but you get the idea.

于 2012-05-02T20:51:40.713 回答
0

Unicode 技术委员会接受了提议的 unicode 代码位置 ₹(来自维基百科),因此您可以更改您的 html 以添加这些字符序列。

有人在他的 MVC WebGrid 项目中展示了这个符号。看这里:

如何在 mvc-webgrid 中显示印度货币符号

 grid1.Column("EmpName",format: (item) => new HtmlString("&#x20B9; " + Convert.ToString( item.Salary)), header: "Notes")))

我只想说我们还有其他方法可以做到这一点..所以试着分享一下..

谢谢

于 2013-10-11T12:58:14.787 回答
0

你可以通过三种方式实现这一点,我知道

  1. 以编程方式,只需覆盖文化

    { System,Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en:IN"); }

  2. 可以逐页覆盖,在要覆盖的页面顶部,您可以查看页面的详细信息,例如语言等。那里只是添加,

    <%@ Page **Culture="en-IN"** Language = "C#".....>

  3. 在 web.config 文件中,在配置标签下

      <System.Web>
           <Globalization Culture="en:IN"/>
      </System.Web>
    

而已 !!我们完了...:)

也可以通过使用该 gridview 控件的 RowDataBound 事件对 gridview 控件中的每一行执行此操作。

谢谢 !!

于 2015-09-10T11:44:13.177 回答