Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

How to format date bound to a datalist?

  Asked By: Maddison    Date: Oct 12    Category: Asp.net    Views: 3540
  

below is my code:


<asp:DataList id="DataList1" runat="server" GridLines="None" width="100%">
<ItemTemplate>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr><td>Booked Date</td>
<td><asp:Label id="lbl_BookDate" runat="server" text='<%#
container.dataitem("BookDate")%>'/></td></tr>
</table>
</ItemTemplate>
</asp:DataList>

Can I know how to format the date to ddmmyyyy? I know I can do it in
Datagrid with this code:
<asp:BoundColumn DataField="BookDate" HeaderText="Book Date"
DataFormatString="{0:dd/MM/yyyy}">

But how do I do it in datalist? Can anyone help?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Josie Roberts     Answered On: Oct 12



<%# DataBinder.Eval(Container.DataItem, "BookDate").ToString("ddMMyyyy") %>

 
Answer #2    Answered By: Marc Anderson     Answered On: Oct 12

The date  column will be formatted in ddmmyyyy format
when you set the culture as "en_GB" in the web.config.

 
Didn't find what you were looking for? Find more on How to format date bound to a datalist? Or get search suggestion and latest updates.




Tagged: