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
Solved

Date Time issue with EditTemplate and Gridview

Posted on 2013-02-03
8
338 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

789 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