?
Solved

Listbox hidden field

Posted on 2007-03-27
3
Medium Priority
?
686 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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