Link to home
Start Free TrialLog in
Avatar of gfedz
gfedzFlag for United States of America

asked on

Combine two database columns into one string in a drop down list

I have a drop down list that needs to be populated with an output of two different columns combined into one.  I need to do this by the vb code behind and not query string so when the user selects a value in the dropdownlist I can make a query off that selection and resplit the two columns.  So far I have this code and it just displays the Vehicle table but I need LocationDescription + Vehicle on one index.
ElseIf ddlSelectGSA.SelectedValue = "Joint" Then
            ddlShow.Items.Clear()
            ddlShow.Visible = True
            sql = "SELECT LocationDescription, Vehicle FROM VehicleScheduler.dbo.tblVehicles ORDER BY LocationDescription"
            myDataTable = New DataTable
            myDataTable = getData(sql)

            ddlShow.Items.Add(New ListItem("", "0"))
            buildDD(sql, ddlShow)
            ValReqDDLSelect.Visible = False

Open in new window

Avatar of Jesus Rodriguez
Jesus Rodriguez
Flag of United States of America image

You can do it by adding more than one colum to the drop down. Check this link that I have from codeproject and you can get the code from there

http://www.codeproject.com/KB/custom-controls/multiColsDD_List.aspx
Avatar of soujanya_g
soujanya_g

Hi
You get 2dattabase colums as one colum by concating them in procedur as

Select Column1+ "  "+Column2 as YourColumn from table

and populate your dropdown list
ASKER CERTIFIED SOLUTION
Avatar of amarsale
amarsale
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gfedz

ASKER

That's what I was looking for.  Thank you.