Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Show Date only from DateTime in DataGrid

Reply
Thread Tools

Show Date only from DateTime in DataGrid

 
 
Xarky
Guest
Posts: n/a
 
      04-25-2005
Hi,
I am using the following code to display a datagrid on my page. Now
one of the columns is of type DateTime(DataField="myDate"). Now when
the datagrid is being shown, the date is given in the following
format: 4/30/2005 12:00:00AM

Now I require to show only the date, ie time is not required. What
code should I add to change the behaviour to that specified.


<aspataGrid id="dataGridNextSessions" runat="server" Height="240px"
Width="312px" BackColor="White" BorderWidth="1px" BorderStyle="None"
BorderColor="#CCCCCC" CellSpacing="2" CellPadding="3"
AllowSorting="True" AutoGenerateColumns="False"
DataKeyField="StudentID">
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#669999"></SelectedItemStyle>
<ItemStyle ForeColor="#000066"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#006699"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="StudentID" HeaderText="Student
ID"></asp:BoundColumn>
<asp:BoundColumn DataField="myDate" HeaderText="Session
Date"></asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" ForeColor="#000066"
BackColor="White" Mode="NumericPages"></PagerStyle>
</aspataGrid>


Can someone help me out
Thanks in Advance
 
Reply With Quote
 
 
 
 
Elton W
Guest
Posts: n/a
 
      04-25-2005
Hi,

You can use DataFormatString to force it display in
specified format, e.g.

<asp:BoundColumn DataField="myDate" DataFormatString="{0:
MM/dd/yyyy}" HeaderText="Session Date"></asp:BoundColumn>


HTH

Elton
http://www.velocityreviews.com/forums/(E-Mail Removed)




>-----Original Message-----
>Hi,
>I am using the following code to display a datagrid on my

page. Now
>one of the columns is of type DateTime

(DataField="myDate"). Now when
>the datagrid is being shown, the date is given in the

following
>format: 4/30/2005 12:00:00AM
>
>Now I require to show only the date, ie time is not

required. What
>code should I add to change the behaviour to that

specified.
>
>
><aspataGrid id="dataGridNextSessions" runat="server"

Height="240px"
>Width="312px" BackColor="White" BorderWidth="1px"

BorderStyle="None"
>BorderColor="#CCCCCC" CellSpacing="2" CellPadding="3"
>AllowSorting="True" AutoGenerateColumns="False"
>DataKeyField="StudentID">
><FooterStyle ForeColor="#000066"

BackColor="White"></FooterStyle>
><SelectedItemStyle Font-Bold="True" ForeColor="White"
>BackColor="#669999"></SelectedItemStyle>
><ItemStyle ForeColor="#000066"></ItemStyle>
><HeaderStyle Font-Bold="True" ForeColor="White"
>BackColor="#006699"></HeaderStyle>
><Columns>
> <asp:BoundColumn DataField="StudentID"

HeaderText="Student
>ID"></asp:BoundColumn>
> <asp:BoundColumn DataField="myDate"

HeaderText="Session
>Date"></asp:BoundColumn>
></Columns>
><PagerStyle HorizontalAlign="Left" ForeColor="#000066"
>BackColor="White" Mode="NumericPages"></PagerStyle>
></aspataGrid>
>
>
>Can someone help me out
>Thanks in Advance
>.
>

 
Reply With Quote
 
 
 
 
xarky d_best
Guest
Posts: n/a
 
      04-25-2005
Hi,
Thanks for your help. Problem solved.



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
linying
Guest
Posts: n/a
 
      05-24-2005
dshdhfkhkklghklgklkh;';kj'lkj;lkj;'l;';lkl;klk;kl; l;kk;lk;l;lk;lk


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [2.4.4] creating a datetime.datetime from an XML xs:dateTime skip@pobox.com Python 2 01-06-2009 01:31 PM
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments