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. Combining two db columns in one dropdown list

Combining two db columns in one dropdown list

Scheduled Pinned Locked Moved C#
databasehelpquestionlearning
5 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.
  • _ Offline
    _ Offline
    _Searcher_
    wrote on last edited by
    #1

    Hi! I'm having a problem whit my page. I have a sql db, and I want to combine to columns, "lastname" and "firstname", from my "user" table. I want to put the the combined two colums in one dropdownlist. This is my sql query: SELECT DISTINCT u.UserID, Firstname, Lastname FROM [User] u, Course_User cu WHERE cu.UserID=u.UserID Does anyone have a suggestion on how i can solve this?

    S H 2 Replies Last reply
    0
    • _ _Searcher_

      Hi! I'm having a problem whit my page. I have a sql db, and I want to combine to columns, "lastname" and "firstname", from my "user" table. I want to put the the combined two colums in one dropdownlist. This is my sql query: SELECT DISTINCT u.UserID, Firstname, Lastname FROM [User] u, Course_User cu WHERE cu.UserID=u.UserID Does anyone have a suggestion on how i can solve this?

      S Offline
      S Offline
      suzyb
      wrote on last edited by
      #2

      You could change the query so it returns the combined first and last names. SELECT DISTINCT u.UserID, Firstname + ' ' + Lastname FROM [User] u, Course_User cu WHERE cu.UserID=u.UserID If I had a better memory I would remember more.

      C _ 2 Replies Last reply
      0
      • _ _Searcher_

        Hi! I'm having a problem whit my page. I have a sql db, and I want to combine to columns, "lastname" and "firstname", from my "user" table. I want to put the the combined two colums in one dropdownlist. This is my sql query: SELECT DISTINCT u.UserID, Firstname, Lastname FROM [User] u, Course_User cu WHERE cu.UserID=u.UserID Does anyone have a suggestion on how i can solve this?

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        What Suzanne said is a good idea. If you want columnar data, however, take a look at Multi-Column ComboBox[^] here on CP. It should give you some ideas and seems to already be data-bindable.

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        • S suzyb

          You could change the query so it returns the combined first and last names. SELECT DISTINCT u.UserID, Firstname + ' ' + Lastname FROM [User] u, Course_User cu WHERE cu.UserID=u.UserID If I had a better memory I would remember more.

          C Offline
          C Offline
          Code Toad
          wrote on last edited by
          #4

          I was going to suggest the very same thing that Suzanne did as this is a quick work around. :) I have also used an ArrayList to help display the two db columns of data. Great article suggested by Heath! Goals are dreams with dates attached.

          1 Reply Last reply
          0
          • S suzyb

            You could change the query so it returns the combined first and last names. SELECT DISTINCT u.UserID, Firstname + ' ' + Lastname FROM [User] u, Course_User cu WHERE cu.UserID=u.UserID If I had a better memory I would remember more.

            _ Offline
            _ Offline
            _Searcher_
            wrote on last edited by
            #5

            Thanks Suzanne! It worked great! :)

            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