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

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.
eddie1747Asked:
Who is Participating?
 
tony_angelopoulosConnect With a Mentor Commented:
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
 
tony_angelopoulosCommented:
do you have a separate edit template?  You might need to specify this in the edit item template as well.
0
 
eddie1747Author Commented:
No I don't have a seperate template. I am just enabling editing within the GridView.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
tony_angelopoulosCommented:
instead of {0:dd/MM/yy} try:
{0:d}

or

d
0
 
eddie1747Author Commented:
{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
 
tony_angelopoulosCommented:
check out this tutorial to see what I am talking about:

http://msdn.microsoft.com/en-us/library/bb288032.aspx
0
 
eddie1747Author Commented:
Creating a seperate template has solved this issue. Many thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.