Quick DropDownList question

Discussion in 'ASP .Net' started by Chris Fulstow, Apr 21, 2006.

  1. 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
     
    Chris Fulstow, Apr 21, 2006
    #1
    1. Advertising

  2. 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.

    "Chris Fulstow" wrote:

    > 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
    >
    >
     
    =?Utf-8?B?Y2xpY2tvbg==?=, Apr 21, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    693
    Iain Norman
    Feb 16, 2005
  2. mr2_93
    Replies:
    1
    Views:
    3,648
    mr2_93
    Oct 2, 2005
  3. tshad
    Replies:
    8
    Views:
    2,254
    tshad
    Oct 19, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,888
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  5. JKop
    Replies:
    11
    Views:
    921
Loading...

Share This Page