The ASP.NET GridView control is used for formatting time on a column and DataFormatString

  • 2020-05-24 05:19:10
  • OfStack

Symptoms: when GridView binds the date format, the date in the database is 2008-07-04, while GridView displays 2007-07-04 000000. ,
Solution: if you want to get rid of the extra zeros, just add a sentence to the source code in the first column of the binding time, as shown in red below
<asp:BoundField DataField="BeginDate" HeaderText=" The start time " 
DataFormatString="{0:d}" htmlencode="false" 
ItemStyle-HorizontalAlign="Center" > 

If there is anything wrong, you are welcome to correct it and make progress together.

Related articles: