Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formating bound data

Status
Not open for further replies.

mych

Programmer
May 20, 2004
248
GB
Hi I'm trying to format a datetime field to just show the date. The datetime is bound to an asp:label and I have tried the following....
Code:
Text= String.Format("{0:D}", '<%# Bind("CReviewDate") %>')
and
Text= String.Format("{0:D}", <%# Bind("CReviewDate") %>)
and 
Text= String.Format("{0:D}", <%# Bind('CReviewDate') %>)
and
Text= String.Format("{0:D}", <%# Bind(CReviewDate) %>)
In all cases I get a green wavy line under the equation and the tip help says "Validation (ASP.Net): If this attribute value is enclosed in quotation marks, the quotation marks must match.

String.Format("{0:D}", DateTime.Now) works fine.
What have I done wrong....

I've not failed! Just found 100 ways that don't work...yet!
 
If the data is coming from a database, then the simplest way is using:
Code:
CONVERT(VARCHAR(12), CReviewDate, 101)

--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top