Dropdown List Box - Adding an item value

Discussion in 'ASP .Net' started by Brian Candy, Feb 20, 2004.

  1. Brian Candy

    Brian Candy Guest

    With a drop down list box, I have discovered how to add a text
    description. Now how do I go about adding a value?

    For FNa = 0 To dsDetails.Tables("Team").Rows.Count - 1
    Row = dsDetails.Tables("Team").Rows(FNa)
    dlTeam.Items.Add(Row.Item("Description"))
    Next

    Thanks in advance

    Brian Candy
    Brian Candy, Feb 20, 2004
    #1
    1. Advertising

  2. Hi, Brian Candy,

    You should use the other overload of the method Add of the
    ListItemCollection class which takes a ListItem object as parameter:

    dlTeam.Items.Add(New ListItem("Text", "Value"))

    http://msdn.microsoft.com/library/e...bcontrolslistitemcollectionclassaddtopic1.asp
    http://msdn.microsoft.com/library/e...emwebuiwebcontrolslistitemclassctortopic3.asp

    Hope this helps
    Martin
    "Brian Candy" <> wrote in message
    news:...
    > With a drop down list box, I have discovered how to add a text
    > description. Now how do I go about adding a value?
    >
    > For FNa = 0 To dsDetails.Tables("Team").Rows.Count - 1
    > Row = dsDetails.Tables("Team").Rows(FNa)
    > dlTeam.Items.Add(Row.Item("Description"))
    > Next
    >
    > Thanks in advance
    >
    > Brian Candy
    Martin Dechev, Feb 20, 2004
    #2
    1. Advertising

  3. use this syntax

    dlTeam.Items.Add(New ListItem("No", 0))
    dlTeam.Items.Add(New ListItem("Yes", 1))

    Regards
    Jose

    "Brian Candy" <> escribió en el mensaje
    news:...
    > With a drop down list box, I have discovered how to add a text
    > description. Now how do I go about adding a value?
    >
    > For FNa = 0 To dsDetails.Tables("Team").Rows.Count - 1
    > Row = dsDetails.Tables("Team").Rows(FNa)
    > dlTeam.Items.Add(Row.Item("Description"))
    > Next
    >
    > Thanks in advance
    >
    > Brian Candy
    Jose Marcenaro, Feb 20, 2004
    #3
    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. Mike
    Replies:
    1
    Views:
    790
  2. QUASAR
    Replies:
    6
    Views:
    405
    QUASAR
    Jan 17, 2004
  3. M. Craig

    How to set background color of List item in dropdown list

    M. Craig, Nov 12, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    274
    M. Craig
    Nov 12, 2003
  4. M. Craig
    Replies:
    1
    Views:
    727
    Victor Garcia Aprea [MVP]
    Jan 9, 2004
  5. SudhaGSD

    adding a check box list item using js

    SudhaGSD, Sep 26, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    95
    SudhaGSD
    Sep 26, 2005
Loading...

Share This Page