Link to home
Start Free TrialLog in
Avatar of bertino12
bertino12

asked on

Listbox hidden field

Is there a hidden field in listbox controls?
Im doing an asp application that has a listbox that has data in it. I need to associate a unique ID with the data, but I dont want to show it.
so the listbox data would actually be like:
234  item1
394  item2
907  item3

but the listbox would just show
item1
item2
item3

How could I set this up?
later i will need to access this data by index.
ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bertino12
bertino12

ASKER

Yes, that has how to add items, which I am already doing, but doesnt really cover anything about hidden fields.

        Dim ds As DataSet
        ds = Me._Helper.popKeywords(intId)
        For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
            Me.lbKeywords.Items.Add(ds.Tables(0).Rows(i).Item("term"))
        Next
        ds = Nothing

currently, this is how I add my items, but my terms need to have a "term_id" associated with them in that control, but the "term_id" cant be seen in the listbox.

ds.Tables(0).Rows(i).Item("term_ID")
This solved my problem. Ill give you credit because you mentioned the text and value properties and it got me looking for a value property.

        Dim ds As DataSet
        ds = Me._Helper.popKeywords(intDecisionId)
        For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
            Me.lbKeywords.Items.Add(ds.Tables(0).Rows(i).Item("term"))
            Me.lbKeywords.Items.Item(i).Value = ds.Tables(0).Rows(i).Item("term_id")
        Next
        ds = Nothing