Hi I'm trying to format a datetime field to just show the date. The datetime is bound to an asp:label and for the Text attribute I have tried the following....

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)

is the syntax that I have been told should work.
What have I done wrong....
I've not failed! Just found 100 (well 4) ways that don't work...yet!

Instead of String.Format(...) have you tried DateTime.Now.ToString("<date format string>") .
Where <date format string> can be any combination of date and time formats.

Or perhaps something dirty like this?

Text= <%# Bind(CReviewDate) %>
Text= DateTime.Parse(Text).ToString("yyyy-MM-dd")

Thanks Oxiegen.... As I'm still a novice I was hoping to stay simple and not have to use code to populate the label. It binds to the data from the db but to keep the display looking simple I just wanted to display the date with no time....
Mych

You're welcome.

Please mark the thread as solved if everything works out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.