[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Formatting Gridview date as mm/dd/yy when editing a Gridview

Posted on 2008-11-04
7
Medium Priority
?
517 Views
Last Modified: 2013-11-26
Hi, I have an ASP.NET Gridview where I have a Date column which I want to be formatted as dd/mm/yy. Therefore I have added DataFormatString="{0:dd/MM/yy}" to the DataField control. This ensures that the dates are displayed as dd/mm/yy in the Gridview however I have editing enabled and when this is used the Gridview still expects an entry in the format mm/dd/yyyy.

Any help on how to rectify this would be much appreciated. Many thanks.
0
Comment
Question by:eddie1747
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:tony_angelopoulos
ID: 22879173
do you have a separate edit template?  You might need to specify this in the edit item template as well.
0
 

Author Comment

by:eddie1747
ID: 22879478
No I don't have a seperate template. I am just enabling editing within the GridView.
0
 
LVL 8

Expert Comment

by:tony_angelopoulos
ID: 22879690
instead of {0:dd/MM/yy} try:
{0:d}

or

d
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Author Comment

by:eddie1747
ID: 22879824
{0:d}  also works fine for displaying the data but its when I come to edit it through the GridView that it expects an entry in the format MM/dd/yyyy hh:mm:ss

Maybe I should have mentioned earlier that I am linking the GridView to a SQL Data Source.

I assume I need to format the actual data at source level rather than just formatting the way it is displayed in the Gridview. Is there a relatively simple way of achieving this this?
0
 
LVL 8

Accepted Solution

by:
tony_angelopoulos earned 150 total points
ID: 22880063
I think that's where an edit template would help.  You could actually specify a calendar control or custom text box control to fix this behavior.
0
 
LVL 8

Expert Comment

by:tony_angelopoulos
ID: 22880097
check out this tutorial to see what I am talking about:

http://msdn.microsoft.com/en-us/library/bb288032.aspx
0
 

Author Closing Comment

by:eddie1747
ID: 31513213
Creating a seperate template has solved this issue. Many thanks.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month19 days, 17 hours left to enroll

873 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