Results 1 to 3 of 3

Thread: RESOLVED!! Adding Text and Value to DropDown

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381

    Question RESOLVED!! Adding Text and Value to DropDown

    How do you add text and Value to a dropdown programatically?

    Right now I use the binding method with no problems.

    VB Code:
    1. DropDownList1.DataTextField = "Name"
    2.             DropDownList1.DataValueField = "CustomerID"
    3.             DropDownList1.DataSource = SQLQuery()
    4.             DropDownList1.DataBind()

    However I have a need to do it manually on some of my dropdown web controls.

    I can add items into the collection but the TEXT and VALUE are both the same when it should have been (ex Finance, 001).

    VB Code:
    1. With DropDownList2
    2.                 .Items.Add("Finance")
    3.                 .Items.Add("Design")
    4.                 .Items.Add("Management")
    5.             End With


    **** DATA ****

    Dept Code
    ------- ------
    FINANCE 001
    DESIGN 002
    MANAGEMENT 003

    TIF
    Last edited by ARPRINCE; Apr 26th, 2004 at 08:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width