GridView DataFormatString not working for varchar dates

R

ronrogell

I would like to format a date field in a GridView that is defined as a
varchar. Here is the bound field that I am trying to format. What am
I doing wrong? Can this only be done for DateTime fields?

<asp:BoundField DataField="FILE_PROCESS_DATE" HeaderText="Process Date"
DataFormatString="{0:MM/dd/yyyy}" HtmlEncode="False" />

Thanks,
Ron
 
K

Ken Cox [Microsoft MVP]

Hi Ron,

You're right. The formatter won't know how to deal with the value if it
isn't a datetime.

Is it possible to convert the existing string into a DateTime so you can
format it the way you want?

Ken
Microsoft MVP [ASP.NET]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,829
Messages
2,569,737
Members
45,521
Latest member
maryb

Latest Threads

Top