Quick DropDownList question

  • Thread starter Thread starter Chris Fulstow
  • Start date Start date
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
 
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.
 
Back
Top