Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How can you show the date in a gridview as a date only instead of a datetime?
  2. ToString("MM/dd/yyyy");
  3.        
  4. <asp:boundfield datafield="MyDate" dataformatstring="{0:MM/dd/yyyy}" />
  5.        
  6. <asp:BoundField HeaderText="Date" DataField="Date_Field" ReadOnly="True" DataFormatString="{0:d}">
  7. </asp:BoundField>
  8.        
  9. convert(varchar, myDate, 101)
  10.        
  11. <itemtemplate>
  12. <asp id="Label1" runat="server" Label.Text='<%# Bind("YourDateField", "{0:M-dd-yyyy}") %>'>;
  13. </asp>
  14. </itemtemplate>