Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 7th, 2006, 04:00 AM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multi column Dropdownlist control???

Hi programmers.
I have a table in my database that contains ID, Name and Family fields. I want to put values of name and family fields in a Dropdownlist in my ASP.NET Project. I set the Datavaluefield of Dropdownlist to "ID" but i don't know how to set the Datatextfield property of my Dropdownlist to show both Name and Family fields?
Please help me.

Reply With Quote
  #2 (permalink)  
Old December 7th, 2006, 05:27 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

You can't do that directly in the control. The easiest way around this is this:

Add an additional column in your query that combines the two fields:

SELECT ID, Name, Family, Name + ' ' + Family AS FamilyName

This combines the two fields on the fly and gives you a new column called FamilyName that you can use in the drop down list.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old December 7th, 2006, 06:01 AM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much comrade. You offered a very good idea....
in my c# code i write:
dropdownlist.datatextfield="FamilyName";
dropdownlist.datavaluefield="ID";

is this true?

thanks again my friend.

Quote:
quote:Originally posted by Imar
 Hi there,

You can't do that directly in the control. The easies way around this is this:

Add an additional column in your query that combines the two fields:

SELECT ID, Name, Family, Name + ' ' + Family AS FamilyName

This combines the two fields on the fly and gives you a new column called FamilyName that you can use in the drop down list.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #4 (permalink)  
Old December 7th, 2006, 06:05 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
quote:is this true?
Why don't you try it out and see for yourself?

But yes, it's true. The new column is available the same way as you would access other columns, so you can set things like DataTextField and DataValueField.

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #5 (permalink)  
Old December 29th, 2006, 01:01 PM
Registered User
 
Join Date: Dec 2006
Location: , , USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you want a more columnar layout -- and not just concatenated fields -- there are some good third-party controls out there like http://easylistbox.com/demoColumns.aspx?rl=wp2p .

Reply With Quote
  #6 (permalink)  
Old January 17th, 2007, 07:24 AM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter, but i prefer to do Imar's offer.

Reply With Quote
  #7 (permalink)  
Old June 7th, 2007, 11:40 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lisackl
Default

Thanks Imar!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi column search and compare luxcs Excel VBA 1 November 16th, 2006 02:45 PM
List Tool Multi Column? Vendlus BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 April 28th, 2006 06:39 AM
DataGrid Multi-Column pbyrum Classic ASP Professional 4 October 5th, 2005 06:02 PM
Multi column combo lists c_olinrb Access 4 July 21st, 2005 09:21 AM
multi-column combo myth12345 VB How-To 1 January 3rd, 2005 04:29 PM



All times are GMT -4. The time now is 08:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.