我在 ASP.Net Gridview 中有以下货币格式表达式。尽管没有错误,但它不显示美元格式。这里缺少什么?
<%# String.Format("{0:C}", Convert.ToString(Eval("Amount")) ) %>
标记
<asp:GridView ID="grdFinancialAmount" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Emp ID">
<ItemTemplate>
<%# Eval("EmpID")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<%# String.Format("{0:C}", Convert.ToString(Eval("Amount")) ) %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
代码背后
protected void Page_Load(object sender, EventArgs e)
{
Financial fin1 = new Financial { EmpID = 1, Amount = 5678 };
Financial fin2 = new Financial { EmpID = 2, Amount = -111111 };
List<Financial> accounts = new List<Financial>();
accounts.Add(fin1);
accounts.Add(fin2);
grdFinancialAmount.DataSource = accounts;
grdFinancialAmount.DataBind();
}
public class Financial
{
public int EmpID { get; set; }
public int Amount { get; set; }
}