Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Gridview date format!!!!

Posted on 2006-06-03
6
Medium Priority
?
8,421 Views
Last Modified: 2012-06-27
I am using gridview to display dates from a datetime filed in a sql server 2005 database. The gridview dislpays the full date with the time. I want to trim off the time and display the date only. I have read up on how to do this, but it is not working for some reason.

In the gridview properties, it has a dataformatstring property. I am trying to use the "{0:d}" format string for short date. I even went into the source and hard coded DataFormatString="{0:d}".

The gridview seems to ignore any formatting I attempt to use.

Any help would be greatly appreciated.
0
Comment
Question by:phil301
6 Comments
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 200 total points
ID: 16824613
Try this:

DataFormatString="{0:yyyy/MM/dd}"

Bob
0
 

Author Comment

by:phil301
ID: 16824910
That doesnt seem to work either. I get no response from the field. I know its the right field, I can leave off the bracket and it will error out. Any other suggestions?
0
 
LVL 27

Accepted Solution

by:
Sammy earned 300 total points
ID: 16824952
use this
<asp:boundfield datafield="datecolum" dataformatstring="{0:MM/dd/yy}" htmlencode="false" />
without the htmlencode attribute set to false you will get the time added as well

HTH
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:phil301
ID: 16825062
You da man!!!! htmlencode = "False" did the trick.
0
 
LVL 27

Expert Comment

by:Sammy
ID: 16825070
Glad it worked for you

Good luck
0
 
LVL 2

Expert Comment

by:bischofb_CRNET
ID: 21075278
here is a cool post I found that shows you how to do it so that you do it and apply the change to all dates using the Culture info.

http://forums.asp.net/p/1223734/2190227.aspx#2190227
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

578 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