Solved

Date Time issue with EditTemplate and Gridview

Posted on 2013-02-03
8
341 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 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