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 fill problem

dropdownlist fill problem

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestion
7 Posts 3 Posters 1 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.
  • E Offline
    E Offline
    Enobong Adahada
    wrote on last edited by
    #1

    pls i have a dropdown list which gets data from my database, i want it to be filled only once when the page is loaded. pls how do i archieve this. thanks.

    G E 2 Replies Last reply
    0
    • E Enobong Adahada

      pls i have a dropdown list which gets data from my database, i want it to be filled only once when the page is loaded. pls how do i archieve this. thanks.

      G Offline
      G Offline
      Gaurav Dudeja India
      wrote on last edited by
      #2

      put the databinding in !ispostback i.e. if(!ispostback) { ddl.bind(); }

      Gaurav Dudeja http://www.gdinfotechindia.com
      Dont be afraid of changing your life to better !

      1 Reply Last reply
      0
      • E Enobong Adahada

        pls i have a dropdown list which gets data from my database, i want it to be filled only once when the page is loaded. pls how do i archieve this. thanks.

        E Offline
        E Offline
        Enobong Adahada
        wrote on last edited by
        #3

        I have done so, i put the code snipet in the page load event, it is giving me object refrence not set to an instance of an object, pls what didi i do wrong thank you.

        B 1 Reply Last reply
        0
        • E Enobong Adahada

          I have done so, i put the code snipet in the page load event, it is giving me object refrence not set to an instance of an object, pls what didi i do wrong thank you.

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #4

          Also set the datasource property as

          if(!IsPostBack)
          {
          ddl.DataSource = collection;//Set the records from db here
          ddl.DataBind();
          }

          Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0

          E 1 Reply Last reply
          0
          • B Brij

            Also set the datasource property as

            if(!IsPostBack)
            {
            ddl.DataSource = collection;//Set the records from db here
            ddl.DataBind();
            }

            Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0

            E Offline
            E Offline
            Enobong Adahada
            wrote on last edited by
            #5

            thank you for your reply, I am using dataset to load the tables, i then assign the column i want to show to the list. how do i databind with the dataset object. thank you

            E B 2 Replies Last reply
            0
            • E Enobong Adahada

              thank you for your reply, I am using dataset to load the tables, i then assign the column i want to show to the list. how do i databind with the dataset object. thank you

              E Offline
              E Offline
              Enobong Adahada
              wrote on last edited by
              #6

              it is working now.. thanks everybody.

              1 Reply Last reply
              0
              • E Enobong Adahada

                thank you for your reply, I am using dataset to load the tables, i then assign the column i want to show to the list. how do i databind with the dataset object. thank you

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

                set like this

                ddl.DataValueField = "columnname1";//for ID
                ddl.DataTextField = "columnname2";// for Value
                ddl.DataSource = datatable;
                ddl.DataBind();

                Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0

                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