469,619 Members | 1,855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,619 developers. It's quick & easy.

Add Code and decode to listbox

Newbie alert!
I have a webform listbox with what I am sure is a common requirement. I wish
to store a list of values but display a "translation" or decode. An example
would be 1, 2, 3, 4 and One, Two, Three, Four

I created

class ListBoxSpecial
public string Code;
public string Decode;

public override string ToString()
return Decode;

public ListBoxSpecial (string Code, string Decode)
this.Code = Code;
this.Decode = Decode;

I then populate the listbox, ListBox1 on page load. E.g. I loop round doing

ListBox1.Items.Add(new ListBoxSpecial(myCode, MyDecode)

I was hoping the ListBox would display

but when selected I could return "2" or whatever code/decode was
appropriate. However when I try this I get the error
The best overloaded method match for
'System.Web.UI.WebControls.ListItemCollection.Add( string)' has some invalid
Argument '1': cannot convert from 'myproj.WebForm1.ListBoxSpecial' to

Any help would be gratefully received.


Nov 17 '05 #1
0 1375

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Chris McKeever | last post: by
1 post views Thread by David Stephenson | last post: by
10 posts views Thread by N | last post: by
2 posts views Thread by Chris | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.