Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ASP.Net GridView Displaying DateTime value in the format 'dd-MM-yy' [modified]

ASP.Net GridView Displaying DateTime value in the format 'dd-MM-yy' [modified]

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdesign
4 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    A Redha
    wrote on last edited by
    #1

    Hi,
    'm using a GridView in my website. I want to display DateTime Values using the format "dd/MM/yy". The Problem is that my WebGrid displays some data correctly but not all of them
    (Jan 30 2008) is displayed "01-01-08"
    (Feb 04 2008) is displayed "02-04-08"
    Some code snippets :
    <asp:gridview id="invoicesGridView" ..../ > <columns> <asp:boundfield datafield="CmdDate" headertext="Date" sortexpression="Date" DataFormatString="{0:dd/MM/yy}" HtmlEncode="False"> .... </asp:boundfield>
    Note : When I tried to set HtmlEncodeFormatString to "False", my web page returns the error message :
    Type 'System.Web.UI.WebControls.BoundField' does not have a public property named 'HtmlEncodeFormatString' !!!
    Thanks in advance.

    Rédha.

    modified on Monday, February 04, 2008 10:17:28 AM

    B 1 Reply Last reply
    0
    • A A Redha

      Hi,
      'm using a GridView in my website. I want to display DateTime Values using the format "dd/MM/yy". The Problem is that my WebGrid displays some data correctly but not all of them
      (Jan 30 2008) is displayed "01-01-08"
      (Feb 04 2008) is displayed "02-04-08"
      Some code snippets :
      <asp:gridview id="invoicesGridView" ..../ > <columns> <asp:boundfield datafield="CmdDate" headertext="Date" sortexpression="Date" DataFormatString="{0:dd/MM/yy}" HtmlEncode="False"> .... </asp:boundfield>
      Note : When I tried to set HtmlEncodeFormatString to "False", my web page returns the error message :
      Type 'System.Web.UI.WebControls.BoundField' does not have a public property named 'HtmlEncodeFormatString' !!!
      Thanks in advance.

      Rédha.

      modified on Monday, February 04, 2008 10:17:28 AM

      B Offline
      B Offline
      bokuceres
      wrote on last edited by
      #2

      have you check your data in your database that been bind to your gridview ? i put the same code in with you in my project, and it works just fine my code : asp:boundfield headertext="Preferred Date to Call" datafield="CallPreferredDate" sortexpression="CallPreferredDate" DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="false" itemstyle width="25%" asp:boundfield hope it helps nb:what the heck in the worls, if i put some code in this text editor, my code will not be shown?

      A 1 Reply Last reply
      0
      • B bokuceres

        have you check your data in your database that been bind to your gridview ? i put the same code in with you in my project, and it works just fine my code : asp:boundfield headertext="Preferred Date to Call" datafield="CallPreferredDate" sortexpression="CallPreferredDate" DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="false" itemstyle width="25%" asp:boundfield hope it helps nb:what the heck in the worls, if i put some code in this text editor, my code will not be shown?

        A Offline
        A Offline
        A Redha
        wrote on last edited by
        #3

        In my laptop, it works fine but the problem occured when I hosted it !! :( I will Keep the default values set for the Date Column and use the RowDatabound Event, it should works !! Thank You boku NB. To display HTML Code, you have to disable the "Ignore HTML tags in this message (good for code snippets)" checkbox bellow the text editor !!

        Rédha.

        B 1 Reply Last reply
        0
        • A A Redha

          In my laptop, it works fine but the problem occured when I hosted it !! :( I will Keep the default values set for the Date Column and use the RowDatabound Event, it should works !! Thank You boku NB. To display HTML Code, you have to disable the "Ignore HTML tags in this message (good for code snippets)" checkbox bellow the text editor !!

          Rédha.

          B Offline
          B Offline
          bokuceres
          wrote on last edited by
          #4

          ooohhh ok. but be careful if your laptop's regional settings is different with your servers. if that's happens, i may suggest, you can use CultureInfo class. yes. you were right. i just know that when i posted it... :p thank you too redha

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups