Can't format a databound date

Discussion in 'ASP .Net' started by cmay, Feb 22, 2006.

  1. cmay

    cmay Guest

    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?
     
    cmay, Feb 22, 2006
    #1
    1. Advertising

  2. 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?
    >
    >
     
    =?Utf-8?B?RWx0b24gVw==?=, Feb 22, 2006
    #2
    1. Advertising

  3. cmay

    cmay Guest

    That did it!

    Thanks
     
    cmay, Mar 7, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,168
    Janaka
    Feb 18, 2004
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,271
    Michael Borgwardt
    May 30, 2004
  3. rodchar
    Replies:
    0
    Views:
    395
    rodchar
    Nov 26, 2007
  4. Vaughn Haybittle

    Format Date in Databound column

    Vaughn Haybittle, Jan 18, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    1,055
    Eliyahu Goldin
    Jan 18, 2007
  5. Manu
    Replies:
    0
    Views:
    170
Loading...

Share This Page