asp:GridView绑定字段格式化的有关问题,求解决
asp:GridView绑定字段格式化的问题,求解决!
我用asp:GridView设置了绑定列,已经设置了列的格式化字符串,HtmlEncode也设置成false了,可给DataSource绑定到一个DataTable,页面的显示还是没有格式化。我想格式化成2位小数,是我的格式化字符串设置有问题吗?求大神指点!
我在后台给GridView绑定一个DataTable后,页面的显示没有格式化,如下图:
------解决方案--------------------
DataFormatString = "{0:F}"
试试看?
------解决方案--------------------
DataFormatString="{0:F2}"
如果不行就说明你的不是数值型字段
我用asp:GridView设置了绑定列,已经设置了列的格式化字符串,HtmlEncode也设置成false了,可给DataSource绑定到一个DataTable,页面的显示还是没有格式化。我想格式化成2位小数,是我的格式化字符串设置有问题吗?求大神指点!
<asp:GridView ID="GridView1" runat="server" BorderColor="#FF8060"
BorderStyle="None" ShowHeader="False" Width="396px"
AutoGenerateColumns="False" BorderWidth="0px">
<Columns>
<asp:BoundField DataField="Value" DataFormatString="{0:N2}" HtmlEncode="False"
ReadOnly="True">
<ItemStyle BorderColor="#FF8060" BorderStyle="Solid" BorderWidth="1px" />
</asp:BoundField>
</Columns>
<RowStyle BorderColor="#FF8060" BorderStyle="Solid" HorizontalAlign="Left"
VerticalAlign="Middle" BorderWidth="1px" />
</asp:GridView>
我在后台给GridView绑定一个DataTable后,页面的显示没有格式化,如下图:
------解决方案--------------------
DataFormatString = "{0:F}"
试试看?
------解决方案--------------------
DataFormatString="{0:F2}"
如果不行就说明你的不是数值型字段