In DataGridView, Change the cell value use my own date format.

I have a datagridview with a column populated from a datetime field. I would like to change the date format to "31/Dec/2009" (no follow the server date format).

I used the following code to display the date, it is work when I test in my PC.

<asp:boundfield headertext="Join Date" datafield="joindate" dataformatstring="{0:dd/MMM/yyyy}" >

but after I upload to the web server, it cannot work!

After research, a setting in the grid columns - HtmlEncode="false" and it should be used when the formats as specifified in the dataformat string.

<asp:boundfield headertext="Join Date" datafield="joindate" dataformatstring="{0:dd/MMM/yyyy}" htmlencode="False"> </asp:boundfield>

0 comments: