Date Time issue with EditTemplate and Gridview

I recently had a question answered about formatting the way a date was displayed in a gridview, so I has 31/01/2013 00-00-00, adding {0:dd-MM-yyyy}, then took out the time and solved my issue.
I'm new to this and can't work out how I would fix this in a edittemplate field with a calendar control embedded ??
ndr-itsolutionsAsked:
Who is Participating?
 
Monica PConnect With a Mentor Software DeveloperCommented:
in case of bound field

<asp:BoundField DataField="date1" ApplyFormatInEditMode="True" HeaderText="date1"  htmlencode="false"
       SortExpression="date1" DataFormatString="{0:d}" />

if you use textbox or ajax control to display

<asp:TextBox id="txtDate" runat="server" text='<%# Eval("Your_Date_Column", "{0:MMMM d, yyyy}") %>

<ajaxToolkit:CalendarExtender ID="cal" runat="server" PopupButtonID="txt"
                                                                        TargetControlID="txte" CssClass="AjaxCalendar" Format="dd/MM/yyyy" />
0
 
Obadiah ChristopherCommented:
What calendar control are you using?
0
 
ndr-itsolutionsAuthor Commented:
The standard calendar control that comes with Web Developer Express 2010.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Obadiah ChristopherCommented:
I'm sorry but why are you looking for the dateformat? Could you elaborate the question a bit
0
 
ndr-itsolutionsAuthor Commented:
When I select a date within the calendar, it appears as 31/01/2013 00:00:00, when I update the gridview. However on columns that I don't have as edit templates I simply add the {0:dd-MM-yyyy} to dataformatstring column.
0
 
Obadiah ChristopherCommented:
Are you using SqlDataSource?
0
 
ndr-itsolutionsAuthor Commented:
Yes
0
 
Obadiah ChristopherCommented:
In case you are using a label

Use
Text='<%# Eval("DateColumn","{0:dd-MM-yyyy}") %>'

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.