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. Dropdownlist selected Item

Dropdownlist selected Item

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelp
9 Posts 6 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.
  • R Offline
    R Offline
    Rajiya
    wrote on last edited by
    #1

    hi, I have a DropdownList called as ddItems.I am populating this dropdown with the Item names from the Database.I have a textbox called as txtName. Now I want to display the name of the Item in the textBox txtname depending on the value selected from the dropdownlist box ddlItems. The code i am using is string selvalue = ddlItems.SelectedItem.Value; txtName.Text = selvalue; But it always displays the first value from the dropdownlist in the textbox. Plz help me.I am using ASP.Net and C#. Riz -- modified at 0:56 Tuesday 28th February, 2006

    E R P L 4 Replies Last reply
    0
    • R Rajiya

      hi, I have a DropdownList called as ddItems.I am populating this dropdown with the Item names from the Database.I have a textbox called as txtName. Now I want to display the name of the Item in the textBox txtname depending on the value selected from the dropdownlist box ddlItems. The code i am using is string selvalue = ddlItems.SelectedItem.Value; txtName.Text = selvalue; But it always displays the first value from the dropdownlist in the textbox. Plz help me.I am using ASP.Net and C#. Riz -- modified at 0:56 Tuesday 28th February, 2006

      E Offline
      E Offline
      enjoycrack
      wrote on last edited by
      #2

      this can be done by using js << >>

      R 1 Reply Last reply
      0
      • E enjoycrack

        this can be done by using js << >>

        R Offline
        R Offline
        Rajiya
        wrote on last edited by
        #3

        Hey, Thanks for the response.This is very urgent for me.If u have any js code for it then plz send it to me. Dropdownlist is always displaying the first record and same gets populated in the textbox.The selected Index of the texbox is always zero even after selecting he items from the dropdownlist......am trying to break my head on this. Thanks riz

        E 1 Reply Last reply
        0
        • R Rajiya

          Hey, Thanks for the response.This is very urgent for me.If u have any js code for it then plz send it to me. Dropdownlist is always displaying the first record and same gets populated in the textbox.The selected Index of the texbox is always zero even after selecting he items from the dropdownlist......am trying to break my head on this. Thanks riz

          E Offline
          E Offline
          enjoycrack
          wrote on last edited by
          #4

          You can write a small function js code to hook on Onchange event of drop down list then, in the function, just simply get the selected value from drop down list and assign to the text box << >>

          1 Reply Last reply
          0
          • R Rajiya

            hi, I have a DropdownList called as ddItems.I am populating this dropdown with the Item names from the Database.I have a textbox called as txtName. Now I want to display the name of the Item in the textBox txtname depending on the value selected from the dropdownlist box ddlItems. The code i am using is string selvalue = ddlItems.SelectedItem.Value; txtName.Text = selvalue; But it always displays the first value from the dropdownlist in the textbox. Plz help me.I am using ASP.Net and C#. Riz -- modified at 0:56 Tuesday 28th February, 2006

            R Offline
            R Offline
            Ritesh1234
            wrote on last edited by
            #5

            Hi, I guess you forgot to put the IsPostBack check in ur page load event that's why it populating your combobox during everypost back and ur getting the first value... Regards, Ritesh

            1 Reply Last reply
            0
            • R Rajiya

              hi, I have a DropdownList called as ddItems.I am populating this dropdown with the Item names from the Database.I have a textbox called as txtName. Now I want to display the name of the Item in the textBox txtname depending on the value selected from the dropdownlist box ddlItems. The code i am using is string selvalue = ddlItems.SelectedItem.Value; txtName.Text = selvalue; But it always displays the first value from the dropdownlist in the textbox. Plz help me.I am using ASP.Net and C#. Riz -- modified at 0:56 Tuesday 28th February, 2006

              P Offline
              P Offline
              Prasad Babu A
              wrote on last edited by
              #6

              Hi, how ur populating dropdownlist, 1st check that one. if u r populating at page_load, plz write ur code under this condition if(!IsPostBack) { //populate ur DropDownList } then u can write string selvalue = ddlItems.SelectedItem.Value; txtName.Text = selvalue; in SelectIndexChanged event. Bye Pessi

              R 1 Reply Last reply
              0
              • P Prasad Babu A

                Hi, how ur populating dropdownlist, 1st check that one. if u r populating at page_load, plz write ur code under this condition if(!IsPostBack) { //populate ur DropDownList } then u can write string selvalue = ddlItems.SelectedItem.Value; txtName.Text = selvalue; in SelectIndexChanged event. Bye Pessi

                R Offline
                R Offline
                Rajiya
                wrote on last edited by
                #7

                hi, Thanks a lot, i had not included the IsPostBack on the Page load.Now it's working fine.....:) Riz

                I 1 Reply Last reply
                0
                • R Rajiya

                  hi, I have a DropdownList called as ddItems.I am populating this dropdown with the Item names from the Database.I have a textbox called as txtName. Now I want to display the name of the Item in the textBox txtname depending on the value selected from the dropdownlist box ddlItems. The code i am using is string selvalue = ddlItems.SelectedItem.Value; txtName.Text = selvalue; But it always displays the first value from the dropdownlist in the textbox. Plz help me.I am using ASP.Net and C#. Riz -- modified at 0:56 Tuesday 28th February, 2006

                  L Offline
                  L Offline
                  Lav KG
                  wrote on last edited by
                  #8

                  Hi, I think it will work when you enable the AutopostBack Property of the dropDownList. And check the IsPostBack Condition on PageLoad funciton if (IsPostBack) { TextBox1.Text = DropDownList1.SelectedItem.Text; } else { .. .. } Thanks Max

                  1 Reply Last reply
                  0
                  • R Rajiya

                    hi, Thanks a lot, i had not included the IsPostBack on the Page load.Now it's working fine.....:) Riz

                    I Offline
                    I Offline
                    Ista
                    wrote on last edited by
                    #9

                    and don't add javascript to manage the drop down list. thats a no-no!:confused: 1 line of code equals many bugs. So don't write any!!

                    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