Solved

Date Time issue with EditTemplate and Gridview

Posted on 2013-02-03
8
337 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
  • 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript to set controls visibility 5 36
mail.To.Add 5 26
Call windows 10 virtual keyboard from windows forms app 2 36
start a process from a service 3 23
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

777 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