Solved

Date Time issue with EditTemplate and Gridview

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

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now