|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Show Date only from DateTime in DataGridI 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. <asp:DataGrid 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> </asp:DataGrid> Can someone help me out Thanks in Advance 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 elton_w***@hotmail.com >-----Original Message----- page. Now>Hi, >I am using the following code to display a datagrid on my >one of the columns is of type DateTime (DataField="myDate"). Now when>the datagrid is being shown, the date is given in the required. Whatfollowing >format: 4/30/2005 12:00:00AM > >Now I require to show only the date, ie time is not >code should I add to change the behaviour to that BackColor="White"></FooterStyle>specified. > > ><asp:DataGrid 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" Show quoteHide quote ><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> ></asp:DataGrid> > > >Can someone help me out >Thanks in Advance >. >
Paging with Datagrid Control
Change/read value from control in EditItemTemplate how can I get the DataKeyField TextBox Value ItemCreated question Datagrid column formatting Export to excel problem Need to create Hieararical DataGrid using ASP.Net Datagrid !!! button column how to use hyper columns in datagrid |
|||||||||||||||||||||||