Results 1 to 7 of 7

Thread: Display Only Date in GRDVIEW

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2008
    Posts
    474

    Display Only Date in GRDVIEW

    Im My Gridview ,date is coming along with time.My date is in format dd/mm/yyy -
    To display only the date in Grdview,I used
    Code:
    <asp:BoundField DataField="EFFECTIVE_DATE" DataFormatString="{0:dd/MM/yyyy}" 
                             HeaderText="Effective Date" />
    But this code is reversing my month & date .See in Pic.
    I want to display only the date??How to do dat??
    Attached Images Attached Images  

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Display Only Date in GRDVIEW

    Hey,

    Have you looked here:

    http://msdn.microsoft.com/en-us/libr...matstring.aspx

    There are various DataFormatString's that you can use.

    Gary

  3. #3
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: Display Only Date in GRDVIEW

    Handle RowDataBound Event

    or

    1> Select Gridview's Smart Tag
    2> Edit Columns
    3> select Column..after choosing column you can see the properties
    4> Fill DataTextProperty = { 0 : d }

    hope that would be the end of it

    hope that helps

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Display Only Date in GRDVIEW

    Quote Originally Posted by dnanetwork View Post
    Handle RowDataBound Event
    For a simple manipulation of the string of the DateTime object, I don't see why this would be required. If there were additional processing required, then I would agree, but in this case, no.

  5. #5
    Hyperactive Member nepalbinod's Avatar
    Join Date
    Sep 2007
    Posts
    293

    Re: Display Only Date in GRDVIEW

    Turn off HtmlEncode

    Code:
    <asp:BoundField DataField="EFFECTIVE_DATE" DataFormatString="{0:dd/MM/yyyy}" 
                             HeaderText="Effective Date" HtmlEncode="false" />
    Or,

    Try this one if this works for you:

    http://hspinfo.wordpress.com/2008/01...nfig-settings/

  6. #6
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: Display Only Date in GRDVIEW

    Yes, nepalbinod is correct.

    I dont know, what exactly it means, but "HtmlEncode" will do the trick..

    Just set it to false and see the magic.

    Experts, Can you give, what exactly it meant and how it will goes ??

    Regards,
    Naga..
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Display Only Date in GRDVIEW

    Hey,

    I really don't understand why setting this property to false:

    http://msdn.microsoft.com/en-us/libr...tmlencode.aspx

    Would change the output that the OP said they were getting.

    sonia, can you show the rendered contents of that cell in both cases?

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width