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. General Programming
  3. C#
  4. combo box

combo box

Scheduled Pinned Locked Moved C#
databasetutorial
7 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.
  • C Offline
    C Offline
    costavo
    wrote on last edited by
    #1

    hi all, how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else

    K M N 3 Replies Last reply
    0
    • C costavo

      hi all, how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      Which technology are you using: Windows Forms, ASP.net, WPF or other?

      1 Reply Last reply
      0
      • C costavo

        hi all, how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else

        M Offline
        M Offline
        Michael Sync
        wrote on last edited by
        #3

        costavo wrote:

        how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else

        SqlConnection dbConn = new SqlConnection ("connectionstring"); dbConn.Open (); SqlDataAdapter da = new SqlDataAdapter ("SELECT town FROM Table", dbConn); da.Fill (ds); DropDownList1.DataSource = ds.Table[0]; DropDownList1.DataBind ();

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

        M 1 Reply Last reply
        0
        • M Michael Sync

          costavo wrote:

          how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else

          SqlConnection dbConn = new SqlConnection ("connectionstring"); dbConn.Open (); SqlDataAdapter da = new SqlDataAdapter ("SELECT town FROM Table", dbConn); da.Fill (ds); DropDownList1.DataSource = ds.Table[0]; DropDownList1.DataBind ();

          Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

          M Offline
          M Offline
          Michael Sync
          wrote on last edited by
          #4

          You can also check my reply here[^]. Hope it helps.

          Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

          1 Reply Last reply
          0
          • C costavo

            hi all, how to add data from database table to the combobox, where i want to read a certain feild and when selected an other feild would be written in somewhere else

            N Offline
            N Offline
            Nouman Bhatti
            wrote on last edited by
            #5

            in addition to the reply of Micheal sync u also have to set the display member and value member properties. set the display member to the field which u want to show. and set the value member to the field which u want to display at some place else. and on selectedindexchanged event set show your selected value ...

            C 1 Reply Last reply
            0
            • N Nouman Bhatti

              in addition to the reply of Micheal sync u also have to set the display member and value member properties. set the display member to the field which u want to show. and set the value member to the field which u want to display at some place else. and on selectedindexchanged event set show your selected value ...

              C Offline
              C Offline
              costavo
              wrote on last edited by
              #6

              please would u give a code example regards

              M 1 Reply Last reply
              0
              • C costavo

                please would u give a code example regards

                M Offline
                M Offline
                Michael Sync
                wrote on last edited by
                #7

                costavo wrote:

                please would u give a code example

                As I replied here,[^] SqlConnection dbConn = new SqlConnection(connectionString); dbConn.Open(); SqlDataAdapter da = new SqlDataAdapter("SELECT town,postal FROM table1", dbConn); DataSet ds = new DataSet(); da.Fill(ds); dbConn.Close(); DropDownList1.DataSource = ds.Tables[0]; **DropDownList1.DataTextField = "town"; DropDownList1.DataValueField = "postalcode";** DropDownList1.DataBind();

                Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

                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