473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Can't format a databound date

I am using asp.net 2.0's gridview to display some data.

My data source is a collection of custom objects.

These objects expose a property which is a date.

When I databind and try to format the date with
DataFormatString="{0:d}", I get no change to the display. I still get
hours/minutes/seconds am/pm in the grid.

If I change my object to return a string instead of a date, then the
format string works like I would expect it to. Is there no way to get
it to format a date object?

I don't want to have to change my strongly typed date property to a
string just for display purposes.

Is there anything I can do?

Feb 22 '06 #1
2 1296
Hi cmay,

Set BoundField's HtmlEncode="False"

HTH

Elton Wang

"cmay" wrote:
I am using asp.net 2.0's gridview to display some data.

My data source is a collection of custom objects.

These objects expose a property which is a date.

When I databind and try to format the date with
DataFormatString="{0:d}", I get no change to the display. I still get
hours/minutes/seconds am/pm in the grid.

If I change my object to return a string instead of a date, then the
format string works like I would expect it to. Is there no way to get
it to format a date object?

I don't want to have to change my strongly typed date property to a
string just for display purposes.

Is there anything I can do?

Feb 22 '06 #2
That did it!

Thanks

Mar 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: goochey | last post by:
I'm trying to convert a Julian Date (Format "4365") into an actual calendar date in Visual Basic, can anyone help me out with this.
10
by: Jack | last post by:
Hi, I cannot get the date format correctly in dynamic sql statement, after trying various ways of handling it. I need some help with the date format in the following dynamic sql statement. Any...
1
by: Naresh | last post by:
Hi All Iam trying to validate date in a databound template textbox column ?To validate date i need to know the id and then which wud allow me to get value in the textbox to search for reg...
8
by: bienwell | last post by:
Hi, I have a problem of displaying data bound by a datalist control. In my table, I have a field Start_date which has Short Date data type. I tried to update this field by Current Date. After...
4
by: Alan Silver | last post by:
Hello, Seems everyone's site nowadays has those "Ads by Goooooogle" boxes on them. I would like to do something similar, so I can provide an affiliate scheme. I don't want to supply HTML for...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
16
by: Mik | last post by:
I apologise if this post seems a little basic, but I am a newbie and have NO access knowledge. I have downloaded the Accounts Ledger from the Microsoft Website. It allows the user to review a...
9
by: Kyote | last post by:
I have a textbox that is databound to a table in an access database. The field only contains month/day/year but my databound textbox is also showing a time. Is there any way to prevent it from...
1
by: David C | last post by:
I am trying to get a LinkButton to show a formatted date as part of the text but it is not working. Below is what I have. MealDate is a valid date, e.g. 11/17/2008. I want it to come out like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.