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
Printable View
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
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>
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>
Right, so change those last two columns to the template columns like this:
would look like: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"/>
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>
thanks, PVB...worked like a charm..
eye