Results 1 to 5 of 5

Thread: format date in a datagrid [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    format date in a datagrid [RESOLVED]

    I'm populating a datagrid and one of the fields is a date. The date comes over with the time. Anyone out there tell me how I can get rid of the time in my datagrid..

    happy halloween
    eye
    Last edited by EyeTalion; Nov 1st, 2002 at 08:54 AM.

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Under the assumption that your mapping up each field and have "AutoGenerateColumns" equal to False this will work with page language="vb":
    Code:
    <Columns>
    	<asp:TemplateColumn HeaderText="CreateDttm">
    		<ItemTemplate>
    			<%# Container.DataItem ( "CreateDttm" ).ToShortDateString() %>
    		</ItemTemplate>
    	</asp:TemplateColumn>
    </Columns>

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    I'm not using templateColumn, heres my code for the datagrid. It's the last two fields that need to be formatted.

    <Columns>
    <asp:BoundColumn DataField="BID_DATE" SortExpression="BID_DATE" HeaderText="DATE"></asp:BoundColumn>
    <asp:BoundColumn DataField="BID_ID" SortExpression="BID_ID" HeaderText="BID"></asp:BoundColumn>
    <asp:BoundColumn DataField="BID_SCHEDULE_DESC" SortExpression="BID_SCHEDULE_DESC" HeaderText="DESCRIPTION"></asp:BoundColumn>
    <asp:BoundColumn DataField="BUYER_NAME" SortExpression="BUYER_NAME" HeaderText="BUYER"></asp:BoundColumn>
    <asp:BoundColumn DataField="EXPR1" SortExpression="EXPR1" HeaderText="POST TO WEB"></asp:BoundColumn>
    <asp:BoundColumn DataField="DISPLAY_START_DATE" SortExpression="DISPLAY_START_DATE" HeaderText="DISPLAY START DATE"></asp:BoundColumn>
    <asp:BoundColumn DataField="DISPLAY_END_DATE" SortExpression="DISPLAY_END_DATE" HeaderText="DISPLAY END DATE"></asp:BoundColumn>
    </Columns>

  4. #4
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Right, so change those last two columns to the template columns like this:
    Code:
    <asp:BoundColumn 
    	DataField="DISPLAY_START_DATE" 
    	SortExpression="DISPLAY_START_DATE" 
    	HeaderText="DISPLAY START DATE"/>
    
    <asp:BoundColumn 
    	DataField="DISPLAY_END_DATE" 
    	SortExpression="DISPLAY_END_DATE" 
    	HeaderText="DISPLAY END DATE"/>
    would look like:
    Code:
    <asp:TemplateColumn
    	SortExpression="DISPLAY_START_DATE" 
    	HeaderText="DISPLAY START DATE">
    	<ItemTemplate>
    		<%# Container.DataItem ( "DISPLAY_START_DATE" ).ToShortDateString() %>
    	</ItemTemplate>
    </asp:TemplateColumn>
    
    <asp:TemplateColumn
    	SortExpression="DISPLAY_END_DATE" 
    	HeaderText="DISPLAY END DATE">
    	<ItemTemplate>
    		<%# Container.DataItem ( "DISPLAY_END_DATE" ).ToShortDateString() %>
    	</ItemTemplate>
    </asp:TemplateColumn>

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    thanks, PVB...worked like a charm..

    eye

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