【发布时间】:2009-11-24 15:37:38
【问题描述】:
我的 Gridview 中有一个绑定字段,它从数据库表中获取其值。
我有数据,但不知道如何在 gridview 中格式化。
例如,我从下面获取总数据,如“123456”,但我想显示为“123,456”
<asp:BoundField DataField="totaldata" HeaderText="Total Data"
ReadOnly="True" SortExpression="totaldata" />
我该怎么做?我需要将绑定字段转换为模板字段吗?但是在那之后我该怎么办。
请帮忙。
我使用过 DataFormatString="{0:n0}" ,它解决了上述问题。
我该怎么做:
<asp:TemplateField HeaderText="Failed Files"
SortExpression="NumFailed">
<ItemTemplate>
<asp:Image ID="Image2" runat="server" ImageUrl="~/NewFolder1/warning_16x16.gif" />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "GetFilesFailed.aspx?id="+Eval("MachineID") %>' Text='<%# Bind("NumFailedFiles") %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
超链接有需要格式化的数字...
【问题讨论】: