VS2005下BoundField的DataFormatString不起作用了?
我们知道在VS2003甚至VS2005Beta下可以用DataFormatString格式化BoundField数据的输出:
<asp:BoundField HeaderText="DisplayText" DataField="FieldName" DataFormatString="{0:F2}">
<ItemStyle HorizontalAlign="Right" Width="60px"></ItemStyle>
<HeaderStyle HorizontalAlign="Right"></HeaderStyle>
</asp:BoundField>
<ItemStyle HorizontalAlign="Right" Width="60px"></ItemStyle>
<HeaderStyle HorizontalAlign="Right"></HeaderStyle>
</asp:BoundField>
但是,很快在VS2005中,你会发现DataFormatString不起作用了。
这时候,应该同时设置HtmlEncode为false,DataFormatString才会起作用:
<asp:BoundField HeaderText="DisplayText" DataField="FieldName" DataFormatString="{0:F2}" HtmlEncode="false">
<ItemStyle HorizontalAlign="Right" Width="60px"></ItemStyle>
<HeaderStyle HorizontalAlign="Right"></HeaderStyle>
</asp:BoundField>
<ItemStyle HorizontalAlign="Right" Width="60px"></ItemStyle>
<HeaderStyle HorizontalAlign="Right"></HeaderStyle>
</asp:BoundField>
Life is like a boat, and I'm at sea.