Solved

Date Time issue with EditTemplate and Gridview

Posted on 2013-02-03
8
340 Views
Last Modified: 2013-02-04
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 ??
0
Comment
Question by:ndr-itsolutions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 38848882
What calendar control are you using?
0
 

Author Comment

by:ndr-itsolutions
ID: 38848906
The standard calendar control that comes with Web Developer Express 2010.
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38848938
I'm sorry but why are you looking for the dateformat? Could you elaborate the question a bit
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:ndr-itsolutions
ID: 38848959
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
 
LVL 20

Expert Comment

by:informaniac
ID: 38848997
Are you using SqlDataSource?
0
 

Author Comment

by:ndr-itsolutions
ID: 38849021
Yes
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38849109
In case you are using a label

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

Open in new window

0
 
LVL 10

Accepted Solution

by:
Monica P earned 500 total points
ID: 38850012
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

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question