开发者

ASP .NET - Format datevalue in GridView that pulls from MySQL table?

The MySQL databa开发者_如何学编程se has a date field in this format:

yyyy-mm-dd (2009-12-01)

When this field is pulled into a Gridview the format changes to:

yyyy-mm-dd HH:mm (2009-12-01 12:00)

How do I get the gridview not to change the default database format?

(most solutions that I have found recommend setting the value in asp:boundfield but this requires the potentially risky HtmlEncode=false)


I don't think that it would be risky to set HtmlEncode = false on date/time field. It's unlikely that any sql injection attack could inject potentially harmful script into a datetime value.

It sounds like the solutions you've found probably refer to setting the DataFormatString and setting HtmlEncode = false. I would go with one of the solutions you've already found.

Or as found here: http://peterkellner.net/2006/05/24/how-to-set-a-date-format-in-gridview-using-aspnet-20using-htmlencode-property/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜