Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2006, 12:40 PM
Friend of Wrox
 
Join Date: Oct 2005
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
The Following 2 Users Say Thank You to rit01 For This Useful Post:
Naveed Alam (October 19th, 2015)
 
Old January 27th, 2006, 01:03 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.
The Following User Says Thank You to Imar For This Useful Post:
Naveed Alam (October 19th, 2015)
 
Old January 27th, 2006, 01:25 PM
Friend of Wrox
 
Join Date: Oct 2005
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
 
Old October 19th, 2015, 10:55 AM
Registered User
 
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#
 
Old May 11th, 2016, 03:22 AM
jasonroy940506
Guest
 
Posts: n/a
Default

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





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 06: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 03:06 PM
Help with DropDownList on String Value Field reidcor BOOK: ASP.NET Website Programming Problem-Design-Solution 1 May 31st, 2005 08:44 AM
datagrid dropdownlist values mlwallin ASP.NET 1.0 and 1.1 Professional 0 July 8th, 2003 06:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.