Solved

Listbox hidden field

Posted on 2007-03-27
3
685 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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