Last post May 20, 2009 03:49 AM by DellaRocco
May 14, 2009 02:55 PM|DellaRocco|LINK
I just try to extend the asp DropDownList and his ListItems, because the "Value" property isn't enough for me and I need a second "Value" property for e.g. "Value2".
Here is the code for my inherited DropDownList:
public class my_DropDownList : DropDownList
Here are my questions:
1. How can I create my own ListItems for my DropDownList with a new property for e.g. "Value2" ?
2. When I can extend the ListItems with the new Property "Value2", how can I create a property for my DropDownList like "SelectedValue2"?
Thank you in advance and sry for me bad english! [;)]
May 18, 2009 02:05 AM|Allen Chen – MSFT|LINK
It's not easy to implement since ListItem is a sealed class.
If you need a "SelectedValue2" why not use some tricks? You can use a symbol to separate two values and assign the entire string to ListItem.Value, such as:
You know the "_" will not appear in the data so it's safe to use it. In other cases where "_" might occur in your data you can use other weird alien word to separate real data.
By spliting the string you can get both values.
May 20, 2009 03:49 AM|DellaRocco|LINK
Thank your for your answer!
When I look at it.....it's so simple! Shame on me! [;)]