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. Visual Basic
  4. Two colomn data bind to one combo box.

Two colomn data bind to one combo box.

Scheduled Pinned Locked Moved Visual Basic
databasewpfwcf
6 Posts 5 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.
  • K Offline
    K Offline
    Kusal
    wrote on last edited by
    #1

    Dear All, I have Table(MS SQL Sever 2000) name "Item" It has two colomn "ItemNo, IName") and it has relevant sample data also. Actually I can bind one colomn data to combo box(Using data set). But I need bind this two colomn("ItemNo", "IName") data in one combo box. Pls, tell me or send sample code for that. I'll think after binding two colomn like this. 00001 - Mother Board 00002 - Mouse 00003 - Key Board. Thanks & Regrds Kusal

    C B M J 4 Replies Last reply
    0
    • K Kusal

      Dear All, I have Table(MS SQL Sever 2000) name "Item" It has two colomn "ItemNo, IName") and it has relevant sample data also. Actually I can bind one colomn data to combo box(Using data set). But I need bind this two colomn("ItemNo", "IName") data in one combo box. Pls, tell me or send sample code for that. I'll think after binding two colomn like this. 00001 - Mother Board 00002 - Mouse 00003 - Key Board. Thanks & Regrds Kusal

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You'll need to build a collection of strings that combines the values and bind to that.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      K 1 Reply Last reply
      0
      • C Christian Graus

        You'll need to build a collection of strings that combines the values and bind to that.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        K Offline
        K Offline
        Kusal
        wrote on last edited by
        #3

        Dear Christian , Many Thanks Best Regards Kusal

        1 Reply Last reply
        0
        • K Kusal

          Dear All, I have Table(MS SQL Sever 2000) name "Item" It has two colomn "ItemNo, IName") and it has relevant sample data also. Actually I can bind one colomn data to combo box(Using data set). But I need bind this two colomn("ItemNo", "IName") data in one combo box. Pls, tell me or send sample code for that. I'll think after binding two colomn like this. 00001 - Mother Board 00002 - Mouse 00003 - Key Board. Thanks & Regrds Kusal

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

          before doing collection of string tell me schould u want to make both in display othervice set data member as one field and value member as other field so it will consider the the value member if u selected the data member i think i am saying in reverse any how it will give u a good result

          with regards Balagurunathan.B

          1 Reply Last reply
          0
          • K Kusal

            Dear All, I have Table(MS SQL Sever 2000) name "Item" It has two colomn "ItemNo, IName") and it has relevant sample data also. Actually I can bind one colomn data to combo box(Using data set). But I need bind this two colomn("ItemNo", "IName") data in one combo box. Pls, tell me or send sample code for that. I'll think after binding two colomn like this. 00001 - Mother Board 00002 - Mouse 00003 - Key Board. Thanks & Regrds Kusal

            M Offline
            M Offline
            Marcus J Smith
            wrote on last edited by
            #5

            Personally I would combine them in your query alone with the original 2 kept separate. So you would so something like the following.

            SELECT (ItemNo + ' - ' + IName) AS CombinedColumns

            That way it is taken care of and you dont have to do any extra work in your code.


            CleaKO

            "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy)
            "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

            1 Reply Last reply
            0
            • K Kusal

              Dear All, I have Table(MS SQL Sever 2000) name "Item" It has two colomn "ItemNo, IName") and it has relevant sample data also. Actually I can bind one colomn data to combo box(Using data set). But I need bind this two colomn("ItemNo", "IName") data in one combo box. Pls, tell me or send sample code for that. I'll think after binding two colomn like this. 00001 - Mother Board 00002 - Mouse 00003 - Key Board. Thanks & Regrds Kusal

              J Offline
              J Offline
              Jaiprakash M Bankolli
              wrote on last edited by
              #6

              I would suggest that you construct SQL statement that concatenates the two column some thing like the following Select (Col1 + ' - ' + Col2) as Col1, Col3 from Table Once you do this you can always bind the col1 to dataText and col3 to datavalue Hope that sounds good to you.

              Regards, Jaiprakash M Bankolli jaiprakash.bankolli@gmail.com

              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