Extended property in listbox item

G

Google User

Hello Everybody,

I am a new bie in ASP.NET. I am populating a listbox control using a
datareader. I set the Value field and text field in the properties
dialog box. I would like to store some other properties with respect
to each item in the list from the data reader. For example my select
statement contains col1, col2, col3 from tableA. I assigned "col1" as
my value field and "col2" as my text field. I would also like to
assign "col3" value to the listitem. Is there any other property in
the listbox where I can assign this value and retrive it after
submitting the form. I remember doing similar thing in VC++ which was
atleast 6 years before. Thanks in advance.
 
K

Ken Cox [Microsoft MVP]

One trick is to store the extra data as part of the value property and
separate each portion of data by a character such as the pipe (|). When you
get the value, just parse out the info that you have delimited.
 
B

Barry Forrest

Another option:
listItem.Attributes.Add("col3", col3) when it is created
and use list.Attributes["col3"] to access the value in the code behind.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top