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. Help Please

Help Please

Scheduled Pinned Locked Moved ASP.NET
helpdatabasesql-serversysadmin
6 Posts 3 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.
  • Y Offline
    Y Offline
    yasso_115
    wrote on last edited by
    #1

    I am using a textbox to insert time into a databse table "SQL Server", The column data type in the table is datetime. When i insert it an run the page i see the date 1/1/1900 in the GridView but i don't want it to appear. What should i do to solve this problem. Thanx in advance for ur help.

    yasso

    S N 2 Replies Last reply
    0
    • Y yasso_115

      I am using a textbox to insert time into a databse table "SQL Server", The column data type in the table is datetime. When i insert it an run the page i see the date 1/1/1900 in the GridView but i don't want it to appear. What should i do to solve this problem. Thanx in advance for ur help.

      yasso

      S Offline
      S Offline
      SABhatti
      wrote on last edited by
      #2

      you have to check the date before displaying on the page, you can do it in sql statement or on rowdatabound, in sql, you can do, case when datefield='1/1/1900' then '' else convert(varchar, datefield, 101) end as datefield in rowdatabound if(row.Cells[datefieldindex].Text=='1/1/1900') row.Cells[datefieldindex].Text = string.Empty;

      -----

      Y 1 Reply Last reply
      0
      • S SABhatti

        you have to check the date before displaying on the page, you can do it in sql statement or on rowdatabound, in sql, you can do, case when datefield='1/1/1900' then '' else convert(varchar, datefield, 101) end as datefield in rowdatabound if(row.Cells[datefieldindex].Text=='1/1/1900') row.Cells[datefieldindex].Text = string.Empty;

        -----

        Y Offline
        Y Offline
        yasso_115
        wrote on last edited by
        #3

        Thx for ur help but i didn't know how to solve it :sigh:, i am a new developer and i have a little experience. Lets say i want to use the rowdatabound, but what is that a property of the Gridview?? I am using a GridView to display the data and one of its columns displayes the time "with the date that i don't want it to appear". where should i put the code that u sent???? Thanx for ur help

        yasso

        S 1 Reply Last reply
        0
        • Y yasso_115

          I am using a textbox to insert time into a databse table "SQL Server", The column data type in the table is datetime. When i insert it an run the page i see the date 1/1/1900 in the GridView but i don't want it to appear. What should i do to solve this problem. Thanx in advance for ur help.

          yasso

          N Offline
          N Offline
          Naif_Prof
          wrote on last edited by
          #4

          Hi, insted of using text box for date user date picker control http://www.basicdatepicker.com/ thanks

          Y 1 Reply Last reply
          0
          • N Naif_Prof

            Hi, insted of using text box for date user date picker control http://www.basicdatepicker.com/ thanks

            Y Offline
            Y Offline
            yasso_115
            wrote on last edited by
            #5

            Thanx Naif i downloaded it and i am using it on the pages but i am using the insert query in the sqldatasource to write to database, all the other controls in the page appear in the controlID: except the timepicker, how can i use it to write data to database?? Thanx for ur help

            yasso

            1 Reply Last reply
            0
            • Y yasso_115

              Thx for ur help but i didn't know how to solve it :sigh:, i am a new developer and i have a little experience. Lets say i want to use the rowdatabound, but what is that a property of the Gridview?? I am using a GridView to display the data and one of its columns displayes the time "with the date that i don't want it to appear". where should i put the code that u sent???? Thanx for ur help

              yasso

              S Offline
              S Offline
              SABhatti
              wrote on last edited by
              #6

              well the following code should be used in your SQL STATEMENT or stored procedure whateevr you are using case when datefield='1/1/1900' then '' else convert(varchar, datefield, 101) end as datefield or use OnRowDataBound="gv_RowDataBound" in html where you insert the gridview control and int he code behind create a sub protected virtual void gv_RowDataBound(object source, gridviewroweventargs e) and use this in this sub if(row.Cells[datefieldindex].Text=='1/1/1900') row.Cells[datefieldindex].Text = string.Empty; look at this [^] for gridview

              -----

              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