Maybe many friends have tried it before, but I just encountered this problem today and solved it after checking the information. Mainly in asp.net 2.0, if you want to display date format, etc. in the binding column, it will not be displayed if you use the following method
<asp :BoundField DataField="CreationDate"
DataFormatString="{0:M-dd-yyyy}"
HeaderText="CreationDate" />
Mainly because the htmlencode attribute is set to true by default, which prevents XSS attacks and is used for security reasons. Therefore, there are two ways to solve it.
1.
<asp :GridView ID="GridView1″ runat="server">
<columns>
<asp :BoundField DataField="CreationDate"
DataFormatString="{0:M-dd-yyyy}"
HtmlEncode="false"
HeaderText="CreationDate" />
</columns>
</asp>
Set htmlencode to false.
Another solution is to use template columns.
<asp :GridView ID="GridView3″ runat="server">
<columns>
<asp :TemplateField HeaderText="CreationDate">
<edititemtemplate>
<asp :Label ID="Label1″ runat="server"
Text='<%# Eval("CreationDate", "{0:M-dd-yyyy}") %>'>
</asp>
</edititemtemplate>
<itemtemplate>
<asp :Label ID="Label1" runat="server"
Text='<%# Bind(“CreationDate”, “{0:M-dd-yyyy}”) %>'>
</asp>
</itemtemplate>
</asp>
</columns>
</asp>
http://www.cnblogs.com/jackyrong/archive/2006/08/28/488282.html