Results 1 to 2 of 2

Thread: [RESOLVED] [2008] Display only Date in gridview and detailsview

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Gothenburg - Sweden
    Posts
    149

    Resolved [RESOLVED] [2008] Display only Date in gridview and detailsview

    hello people

    how can i display only the date in detailview or gridview?!
    by default these two view displays both time and date if the column has a datetime data type.what i need is to display only the date in the column.

    thanks in advance
    In Love With .NET Framwork and Microsoft
    Learning ASP.NET,ADO.NET And VB.NET
    Becoming a Software Engineer...

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Gothenburg - Sweden
    Posts
    149

    Re: [2008] Display only Date in gridview and detailsview

    found it:

    vb Code:
    1. <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    2.         AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
    3.         DataKeyNames="ID" DataSourceID="HomeObjectDataSource" ForeColor="Black"
    4.         BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px"
    5.         CellSpacing="2" Width="900px">
    6.         <FooterStyle BackColor="#CCCCCC" />
    7.         <RowStyle BackColor="White" />
    8.         <Columns>
    9.             <asp:HyperLinkField DataNavigateUrlFields="ID"
    10.                 DataNavigateUrlFormatString="DownloadPage.aspx?ID={0}" HeaderText="Download"
    11.                 Text="Download" />
    12.             <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
    13.             <asp:BoundField DataField="Category" HeaderText="Category"
    14.                 SortExpression="Category" />
    15.             <asp:BoundField DataField="UploadedDate" HeaderText="Uploaded Date"
    16.                 SortExpression="UploadedDate" DataFormatString="{0:d}" />
    17.             <asp:BoundField DataField="PublishedDate" HeaderText="Published Date"
    18.                 SortExpression="PublishedDate" DataFormatString="{0:d}" />
    19.         </Columns>
    20.         <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
    21.         <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    22.         <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
    23.     </asp:GridView>

    notice this part:
    vb Code:
    1. <asp:BoundField DataField="PublishedDate" HeaderText="Published Date"
    2.                 SortExpression="PublishedDate" DataFormatString="{0:d}" />

    this is how to display the date:
    vb Code:
    1. DataFormatString="{0:d}"
    In Love With .NET Framwork and Microsoft
    Learning ASP.NET,ADO.NET And VB.NET
    Becoming a Software Engineer...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width