Thursday, February 18, 2010

Ordered Dictionary

I had an issue with loading a dynamically generated DropDownList options via a XML file. Initially I was loading the options for the dropdownlist from the XML file to a Hashtable. But when I tried to display that the order in which the items were displayed wasn't the way it was loaded.

I tried using SortedList to fix the issue but my users insisted that they need the flexibity of maintaining the order via the XML file.


I changed the SortedList to OrderedDictionary and it solved my problem. The OrderedDictionary retains the order in which the options were inserted. So this solves my customer requirements. From performance wise, it is ok using OrderedDictionary for limited number of options.

No comments:

Post a Comment