Multiple fields in a DropDownList

Discussion in 'ASP .Net' started by tshad, Oct 31, 2005.

  1. tshad

    tshad Guest

    Is there a way to do something like:

    UserList.DataSource=theDataSet
    if ShowUserRoles.Checked then
    UserList.DataTextField= "NameUserName" & " / " & "RoleDescription"
    else
    UserList.DataTextField= "NameUserName"
    end if
    UserList.DataValueField="UserID"
    UserList.databind()

    I could assign a variable to the Select statement that does it, but I would
    prefer to do it here, if possible.

    Thanks,

    Tom
     
    tshad, Oct 31, 2005
    #1
    1. Advertisements

  2. There's no good way to adjust the data once it's in the DropDownList.
    Therefore you should make the change in the underlying DataSet before you
    bind it to the DropDownList. It might be easiest to do this in your initial
    Select statement...
     
    Steve C. Orr [MVP, MCSD], Oct 31, 2005
    #2
    1. Advertisements

  3. tshad

    tshad Guest

    That was what I figured.

    Thanks,

    Tom
     
    tshad, Nov 3, 2005
    #3
  4. As steve adviced just trying doing e.g
    strSQLQuery = "SELECT id, " _
    & "RTRIM(email) + ' ' + RTRIM(lastname) AS name " _
    & "FROM contacts ORDER BY id;"
    Hope that helps
    Patrick
     
    Patrick.O.Ige, Nov 4, 2005
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.