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
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 Display Modes
  #1 (permalink)  
Old January 27th, 2006, 12:40 PM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default 2 field Values within DropDownList.DataValueField

Hi All

Not sure whether it is possible but is there any way to include 2 database fields within the same DropDownList.DataValueField field directly within the control:

Code:
<asp:DropDownList ID="DropDownList1" runat="server" 
DataSourceID="SqlDBSrc" DataTextField="NAME" DataValueField="FIELD1 + 
FIELD2" SelectedValue='<%# Bind("FIELD1ID") %>'>
If not what syntax would you recommend to achieve this?

As always your advice is much appreciated

Rit



Rit
www.designandonline.co.uk
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
Reply With Quote
The Following 2 Users Say Thank You to rit01 For This Useful Post:
Naveed Alam (October 19th, 2015)
  #2 (permalink)  
Old January 27th, 2006, 01:03 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,957
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

Hi Rit,

Unfortunately, you can't.

However, it's pretty easy to combine the columns in your select statement, alias them and then use that alias.

E.g.:

SELECT Field1 + Field2 AS NewColumn FROM Bla bla bla

And then use NewColumn for the DataValueFIeld:

<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDBSrc" DataTextField="NAME" DataValueField="NewColumn" SelectedValue='<%# Bind("FIELD1ID") %>'>

If you post code in this forum, can you please add a line break here and there? Makes the page much easier to read and type replies in...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
Naveed Alam (October 19th, 2015)
  #3 (permalink)  
Old January 27th, 2006, 01:25 PM
Friend of Wrox
 
Join Date: Oct 2005
Location: , , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

Imar, you are a star buddy!

And many thanks for the line break tip ;)

Rit

Rit
www.designandonline.co.uk
Reply With Quote
  #4 (permalink)  
Old October 19th, 2015, 11:55 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2015
Posts: 1
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Sir can you please paste the code in code behind in asp.net c#
Reply With Quote
  #5 (permalink)  
Old May 11th, 2016, 04:22 AM
jasonroy940506
Guest
 
Posts: n/a
Default

Thanks for ideas and solution, that my work i hope in future
Reply With Quote
Reply


Thread Tools
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
How to get the DataValueField of checkboxlist item avilren ASP.NET 1.0 and 1.1 Basics 1 July 13th, 2006 07:18 AM
Passing values from dropdownlist sparc ASP.NET 1.0 and 1.1 Basics 2 October 31st, 2005 09:42 AM
Dropdownlist Values From Database tranzformerz BOOK: Beginning ASP.NET 1.0 2 September 7th, 2005 04:06 PM
Help with DropDownList on String Value Field reidcor BOOK: ASP.NET Website Programming Problem-Design-Solution 1 May 31st, 2005 09:44 AM
datagrid dropdownlist values mlwallin ASP.NET 1.0 and 1.1 Professional 0 July 8th, 2003 07:50 PM



All times are GMT -4. The time now is 09:16 AM.


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