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. how can get the birthday from database to dropdownlist

how can get the birthday from database to dropdownlist

Scheduled Pinned Locked Moved ASP.NET
databaseannouncement
9 Posts 4 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.
  • L Offline
    L Offline
    lolostar
    wrote on last edited by
    #1

    Hi, how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year . I want get the information to update on it . thanks .

    N B S 3 Replies Last reply
    0
    • L lolostar

      Hi, how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year . I want get the information to update on it . thanks .

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Is it stored in the database as a DateTime? If so then you get the same way you would get any other column. Once you have the DateTime object you use the properties the structure, Day, Month, Year to get the constituent parts. In these situations I usually rely on a little trick I like to refer to as Reading the Documentation, or as some abbreviate it, RTFM


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • L lolostar

        Hi, how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year . I want get the information to update on it . thanks .

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #3

        Why you aren't using Calendar1 control? If you have to split birthday value in controls then use Year,Month,Day SQL Functions. e.g

        select year(birthday) from mytable
        select month(birthday) from mytable
        select day(birthday) from mytable


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

        L N 2 Replies Last reply
        0
        • B Blue_Boy

          Why you aren't using Calendar1 control? If you have to split birthday value in controls then use Year,Month,Day SQL Functions. e.g

          select year(birthday) from mytable
          select month(birthday) from mytable
          select day(birthday) from mytable


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

          L Offline
          L Offline
          lolostar
          wrote on last edited by
          #4

          no I don't need to use the calender but I need only return birthdate from database into variable as DateTime and then spilt it into day to put it in the dropdownlist , month into another dropdownlist , year into textbox to update information about user .

          B 1 Reply Last reply
          0
          • L lolostar

            no I don't need to use the calender but I need only return birthdate from database into variable as DateTime and then spilt it into day to put it in the dropdownlist , month into another dropdownlist , year into textbox to update information about user .

            B Offline
            B Offline
            Blue_Boy
            wrote on last edited by
            #5

            So, you can bind dropdowlists and textbox with query which I wrote you in previous post.


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

            1 Reply Last reply
            0
            • B Blue_Boy

              Why you aren't using Calendar1 control? If you have to split birthday value in controls then use Year,Month,Day SQL Functions. e.g

              select year(birthday) from mytable
              select month(birthday) from mytable
              select day(birthday) from mytable


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              So you want to use three query, with all the overhead, to return one value, DateTime, which already has the properties for Day, Month, Year. Even if you combined into one query it is still unnecessary to separate the values in the SQL statement.


              I know the language. I've read a book. - _Madmatt

              B 1 Reply Last reply
              0
              • N Not Active

                So you want to use three query, with all the overhead, to return one value, DateTime, which already has the properties for Day, Month, Year. Even if you combined into one query it is still unnecessary to separate the values in the SQL statement.


                I know the language. I've read a book. - _Madmatt

                B Offline
                B Offline
                Blue_Boy
                wrote on last edited by
                #7

                That was only example about Year,Month,Day SQL functions.


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

                1 Reply Last reply
                0
                • L lolostar

                  Hi, how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year . I want get the information to update on it . thanks .

                  S Offline
                  S Offline
                  Sneha Bisht
                  wrote on last edited by
                  #8

                  how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year . I want get the information to update on it . for that task first you have to create two dropdownlist for day and month and fill them. then try this code void BIndBirthDay() { DateTime _bdate = DateTime.Now; -- get this date from database field int day = _bdate.Day; -- return int value(find day of datetime field like that) drp_day.SelectedIndex = -1; drp_day.Items.FindByValue(Convert.ToString(day)).Selected = true; -- bind that perticulare day to dropdownlist by that } hope this helps and also same down for month (_bdate.Day) and year (_bdate.Year)

                  L 1 Reply Last reply
                  0
                  • S Sneha Bisht

                    how I can get the birthday from column in database ( as datetime type ) and display it in a separate dropdownlist one for day and other for month and textbox for year . I want get the information to update on it . for that task first you have to create two dropdownlist for day and month and fill them. then try this code void BIndBirthDay() { DateTime _bdate = DateTime.Now; -- get this date from database field int day = _bdate.Day; -- return int value(find day of datetime field like that) drp_day.SelectedIndex = -1; drp_day.Items.FindByValue(Convert.ToString(day)).Selected = true; -- bind that perticulare day to dropdownlist by that } hope this helps and also same down for month (_bdate.Day) and year (_bdate.Year)

                    L Offline
                    L Offline
                    lolostar
                    wrote on last edited by
                    #9

                    Yes, that's really what I want thank you very much :)

                    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