Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

dropdownlist binding

Posted on 2004-09-09
7
315 Views
Last Modified: 2010-04-23

Hi

i am binding the data selected from database to dropdownlist.
 
select companynumber, companyname from company
 
dropdownlist.datatextfield = "companyname"
dropdownlist.datavaluefield = "companynumber"
dropdownlist.databind().
 
with this code in the drop down list i will have companynames.
 
what i want is both companyname - companynumber in dropdownlist.
when i am saying dropdownlist.datatextfield = "companyname" & "companynumber" its
throwing error. is there any other way to do it.
0
Comment
Question by:sandeep437
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
tomv011397 earned 125 total points
ID: 12018842
you will need to get that into the query, The 'auto wire up' does not support multiple of user defined fields.

Change your query to

select companyname + " - " + companynumber as displayname
,       CompanyNumber
from ... etc

then link 'displayname' as the display field

TOm
0
 
LVL 1

Expert Comment

by:iamtgo3
ID: 12019396
If you bind it to a field on your query it is hard to add two fields together. You can query the database for the fills and then add to dropdown with a for loop.

I realize these are not the greatest examples but should help steer you in the right direction.

George - www.ipdg3.com
0
 
LVL 7

Expert Comment

by:natloz
ID: 12019999
TOm is correct...change your select statement to include the concatenated value for your combo box.
0
 
LVL 1

Expert Comment

by:iamtgo3
ID: 12020048
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question