Many of my friends have tried this problem before, but I only encountered this problem today. Mainly
In Asp.net 2.0, if you want to display data in the binding column, such as the date format, the following method cannot be used.
<Asp: boundfield datafield = "creationdate"
Dataformatstring = "{0: M-dd-yyyy }"
Headertext = "creationdate"/>
The main reason is that the htmlencode attribute is set to true by default, which has prevented XSS attacks and is used for security reasons. Therefore, there are two solutions:
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 the template column
text = '<% # eval ("creationdate", "{0: M-dd-yyyy }") %> '>
text = '<% # BIND ("creationdate", "{0: M-dd-yyyy }") %> '>