Solved

dropdownlist binding

Posted on 2004-09-09
7
312 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now