Solved

Listbox hidden field

Posted on 2007-03-27
3
671 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:bertino12
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 18802044
yes, there are separate "text" and "value" properties (as well as "index")
here's a pretty comprehensive tutorial on using the listbox:
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=345
0
 

Author Comment

by:bertino12
ID: 18802087
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")
0
 

Author Comment

by:bertino12
ID: 18802199
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
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now