Subject: 2 field Values within DropDownList.DataValueField
Posted By: rit01 Post Date: 1/27/2006 11:40:11 AM
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:


<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
Reply By: Imar Reply Date: 1/27/2006 12:03:13 PM
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 By: rit01 Reply Date: 1/27/2006 12:25:45 PM
Imar, you are a star buddy!

And many thanks for the line break tip

Rit

Rit
www.designandonline.co.uk

Go to topic 39197

Return to index page 384
Return to index page 383
Return to index page 382
Return to index page 381
Return to index page 380
Return to index page 379
Return to index page 378
Return to index page 377
Return to index page 376
Return to index page 375