Quick DropDownList question

C

Chris Fulstow

Hi all,

I've got a simple data-bound DropDownList control:

<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="ObjectDataSource1" DataTextField="EmployeeName"
DataValueField="EmployeeID">
</asp:DropDownList>

I want to DataTextField to include the DataValueField, so my drop-down
list options look like "[EmployeeID] - [EmployeeName]", e.g.

123 - John Smith
456 - Jane Davis

etc.

Is there a way to do this without having to change my data source?

Cheers,
Chris
 
G

Guest

I think you would have to change you data, it would be easy to do this if the
data was coming from and SQL based data source because you could just do
something like:

SELECT EmployeeName + EmployeeID AS EmployeeName, EmployeeID FROM Emplyees;

And you drop down list would contain the values you wanted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top