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. Problem in dropdown

Problem in dropdown

Scheduled Pinned Locked Moved ASP.NET
javascripthelptutorial
5 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.
  • S Offline
    S Offline
    Suamal
    wrote on last edited by
    #1

    In my page i am having a dropdownlist control. I have populated the data for this dropdown using javascript. i.e it has 5 items. But upon postback ,it says that the data in the dropdown is 0.How to solve this.

    T 1 Reply Last reply
    0
    • S Suamal

      In my page i am having a dropdownlist control. I have populated the data for this dropdown using javascript. i.e it has 5 items. But upon postback ,it says that the data in the dropdown is 0.How to solve this.

      T Offline
      T Offline
      TheEagle
      wrote on last edited by
      #2

      I think to make a Postback you must use a control that run at server... May you write your code so you make every thing clear? "I am too late but i will never give up"

      S 1 Reply Last reply
      0
      • T TheEagle

        I think to make a Postback you must use a control that run at server... May you write your code so you make every thing clear? "I am too late but i will never give up"

        S Offline
        S Offline
        Suamal
        wrote on last edited by
        #3

        see my code 1. 2.I have used this javascript to populate the dropdown ( For sample i have used the count,it is getting at runtime) function add() { var ddlobj = document.getElementById('ddemp'); for (var count = ddlobj.options.length-1;count >-1; count--) { ddlobj.options[count] = null; } for (var count = 0; count < 5;count++) // For sample i have used the count,it is getting at runtime { value = count; text = "List" + count ; listItem = new Option(text, value , false, false); ddlobj.options[ddlobj.length] = listItem; } } 3.while clicking one more button, i am not getting the selected value. it shows ddemp.Items.Count as 0

        P 1 Reply Last reply
        0
        • S Suamal

          see my code 1. 2.I have used this javascript to populate the dropdown ( For sample i have used the count,it is getting at runtime) function add() { var ddlobj = document.getElementById('ddemp'); for (var count = ddlobj.options.length-1;count >-1; count--) { ddlobj.options[count] = null; } for (var count = 0; count < 5;count++) // For sample i have used the count,it is getting at runtime { value = count; text = "List" + count ; listItem = new Option(text, value , false, false); ddlobj.options[ddlobj.length] = listItem; } } 3.while clicking one more button, i am not getting the selected value. it shows ddemp.Items.Count as 0

          P Offline
          P Offline
          Paddy Boyd
          wrote on last edited by
          #4

          When you add them on clientside like this, they are not posted back to the server. You might want to consider putting the selected value of this listbox into a hidden field ( i assume that is what you want in the server code.)

          S 1 Reply Last reply
          0
          • P Paddy Boyd

            When you add them on clientside like this, they are not posted back to the server. You might want to consider putting the selected value of this listbox into a hidden field ( i assume that is what you want in the server code.)

            S Offline
            S Offline
            Suamal
            wrote on last edited by
            #5

            Thank You. I will use like that.

            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