Solved

Listbox hidden field

Posted on 2007-03-27
3
683 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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