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. Datagrid-Date Problem

Datagrid-Date Problem

Scheduled Pinned Locked Moved ASP.NET
csshelpquestion
16 Posts 7 Posters 0 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 A kamath

    In my grid view I want to show only date but it is showing date and time. How can I show Date only

    S Offline
    S Offline
    sra22
    wrote on last edited by
    #7

    hi, You can set DataFormatString="{0:d}" to your column in datagrid hope it will work

    1 Reply Last reply
    0
    • S Sathesh Sakthivel

      A kamath wrote:

      I had given like this{dd/mmm/yyyy} but it is showing eror(input string is not in correct format).

      give it as {dd/mm/yyyy} then it will not show Error.

      Regards, Satips.

      A Offline
      A Offline
      A kamath
      wrote on last edited by
      #8

      It is not working

      S C 2 Replies Last reply
      0
      • A A kamath

        It is not working

        S Offline
        S Offline
        Sathesh Sakthivel
        wrote on last edited by
        #9

        Paste your code here we will check it out.

        Regards, Satips.

        A 1 Reply Last reply
        0
        • S Sathesh Sakthivel

          Paste your code here we will check it out.

          Regards, Satips.

          A Offline
          A Offline
          A kamath
          wrote on last edited by
          #10
          S 1 Reply Last reply
          0
          • A A kamath
            S Offline
            S Offline
            Sathesh Sakthivel
            wrote on last edited by
            #11

            :sigh:

            Regards, Satips.

            A 1 Reply Last reply
            0
            • S Sathesh Sakthivel

              :sigh:

              Regards, Satips.

              A Offline
              A Offline
              A kamath
              wrote on last edited by
              #12
              S 1 Reply Last reply
              0
              • A A kamath
                S Offline
                S Offline
                Sathesh Sakthivel
                wrote on last edited by
                #13

                In the BoundField event of the DataGrid, Place you code to convert the format. private void dg_BoundField(object, e) { e.Items[3].Value = ((System.DateTime) e.Items[3]).ToString("dd/MM/yyyy", System.Globalization.DateTimeFormatInfo.InvariantI nfo) } Try with this code this will solve your problem. It will display only date.

                Regards, Satips.

                A 1 Reply Last reply
                0
                • S Sathesh Sakthivel

                  In the BoundField event of the DataGrid, Place you code to convert the format. private void dg_BoundField(object, e) { e.Items[3].Value = ((System.DateTime) e.Items[3]).ToString("dd/MM/yyyy", System.Globalization.DateTimeFormatInfo.InvariantI nfo) } Try with this code this will solve your problem. It will display only date.

                  Regards, Satips.

                  A Offline
                  A Offline
                  A kamath
                  wrote on last edited by
                  #14

                  Thanks

                  S 1 Reply Last reply
                  0
                  • A A kamath

                    Thanks

                    S Offline
                    S Offline
                    Sathesh Sakthivel
                    wrote on last edited by
                    #15

                    Welcome.

                    Regards, Satips.

                    1 Reply Last reply
                    0
                    • A A kamath

                      It is not working

                      C Offline
                      C Offline
                      Chetan Ranpariya
                      wrote on last edited by
                      #16

                      Hi, Better you check for the proper formatstring on the google.

                      Thanks and Regards, Chetan Ranpariya

                      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