• Tue, Aug 2012
  • RSS
  • Newsletter
  • Become a Fan!
  • Follow On Twitter
    • Subcribe to Our RSS Feed

    How To Set a Date Format In GridView Using ASP.NET 2.0

    Posted In Asp.net - By admin On Tuesday, July 28th, 2009 With 1 Comment

    A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type.The problem is the by default, the HtmlEncode property of the boundfield attribute is set to True

    :GridView ID=“GridView1″ runat=“server”>
    >

    :BoundField DataField=“DOB”
    DataFormatString=“{0:M-dd-yyyy}”
    HtmlEncode =“True” HeaderText=“Date of Birth” />
    >
    >

    The second choice is to make the column a template and simply set the format string directly in the Label ,Text Fields or bind data direct as follows.

    :GridView ID=“GridView1″ runat=“server”>
    >


    >
    >
    Tags: ,

    About -

    Displaying 1 Comments
    Have Your Say

    1. Niraj says:

      Please explain in more details

      Thanks….!

      [Reply]

    Leave a comment

    XHTML: You can use these tags: