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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with DropDownList

Problem with DropDownList

Scheduled Pinned Locked Moved ASP.NET
helpquestion
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.
  • N Offline
    N Offline
    nagendrathecoder
    wrote on last edited by
    #1

    Hello all, I am dynamically creating DropDownList in my application. While running application, when i select some value in DropDownList it is showing fine, but if i click some other button then DropDownList is always showing its first item. I heard this happens because of PostBack. I tried by setting AutoPostBack property to both true and false, but still same problem occuring both time. Can anyone help me? Thanks, Nagendra.

    N A 2 Replies Last reply
    0
    • N nagendrathecoder

      Hello all, I am dynamically creating DropDownList in my application. While running application, when i select some value in DropDownList it is showing fine, but if i click some other button then DropDownList is always showing its first item. I heard this happens because of PostBack. I tried by setting AutoPostBack property to both true and false, but still same problem occuring both time. Can anyone help me? Thanks, Nagendra.

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

      Check that you are not rebinding the dropdownlist when the button click causes the postback.


      only two letters away from being an asset

      N 1 Reply Last reply
      0
      • N Not Active

        Check that you are not rebinding the dropdownlist when the button click causes the postback.


        only two letters away from being an asset

        N Offline
        N Offline
        nagendrathecoder
        wrote on last edited by
        #3

        This is my code, i am creating DropDownList inside GridView

        A 1 Reply Last reply
        0
        • N nagendrathecoder

          Hello all, I am dynamically creating DropDownList in my application. While running application, when i select some value in DropDownList it is showing fine, but if i click some other button then DropDownList is always showing its first item. I heard this happens because of PostBack. I tried by setting AutoPostBack property to both true and false, but still same problem occuring both time. Can anyone help me? Thanks, Nagendra.

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          When did you create those Dynamic control. You have to create the dynamic control before page_load(), other wise that control will not be able to maintain viewstate and Postback datra, cause LoadViewState() and LoadPostbackData() called juts before page_load(). IF you created control before page_load, Try to do this in

          Page_Load()

          if( ! Page.IsPostBack)

          {

            // Bind Data With Dropdownlist
          

          }

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          N 1 Reply Last reply
          0
          • N nagendrathecoder

            This is my code, i am creating DropDownList inside GridView

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            You are using it inside Gridview ?

            Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

            1 Reply Last reply
            0
            • A Abhijit Jana

              When did you create those Dynamic control. You have to create the dynamic control before page_load(), other wise that control will not be able to maintain viewstate and Postback datra, cause LoadViewState() and LoadPostbackData() called juts before page_load(). IF you created control before page_load, Try to do this in

              Page_Load()

              if( ! Page.IsPostBack)

              {

                // Bind Data With Dropdownlist
              

              }

              Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

              N Offline
              N Offline
              nagendrathecoder
              wrote on last edited by
              #6

              i am creating it inseide a 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