AttributeCollection problem

J

Jeff

hi

..NET 2.5

On my webpage I have ListBox. When adding items to that ListBox I want for
each item to add an attribute.

( I tryed to use the ListItem.value instead but it doesn't work, it get the
same value as the Text property, so it cannot be NULL, bad idea cause my
code test if the Value is NULL and if NULL then do some logic... )

So instead I'm trying to use AttributeCollection.
ListItem item = new ListItem();
item.Text = "HelloWorld";
item.Attributes.Add("Id", "-1");
ListBox1.Items.Add(item);

Later in my code I try to access that attribute:
string r = item.Attributes["Id"];
There is the problem. Instead of retrieving the value I get NULL
(r = null)

Any ideas what I do wrong here?
 
J

Jeff

Thanks for that link

One thing I don't understand from that link is if I create such myListBox
inherited from ListBox, How should I use it on a webpage, I mean how should
I go about getting this custom class displayed in the webpage?
 

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

Top