Solved

dropdownlist binding

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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