How to bind Generic Dictionary with dropdown list

I was searching for binding the dictionary with dropdown list, the solution I found was consist of binding the Key as ‘DataValueField’ and value as ‘DataTextField’ of dictionary object.

But my problem was to bind the object (value collection of the dictionary)as datasource and its property to the dropdown ‘DataValueField’ and ‘DataTextField’.

The beauty of Generic dictionary object is that it can return you the value collection by using ‘Values’ property of the dictionary.

So here is the example.

<asp:DropDownList

ID="ddlCustomer"

runat="server"

DataSource='<%#Customers.Values%>'

      DataTextField="Name"

DataValueField="ID">

</asp:DropDownList>