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: 3560

below is my code:

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

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"

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



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.