Monday, October 8, 2012

This the question asked by so many people around me and I also faced issues couple of times of my early stages of learning.This is simple but how to get value and names as a collection and bind to drop down list is a bit difficult. 

Below is the simple logic to read all enums and create a list item and bind to drop down list. 
[Note: There are many ways to get this done, but I believe below is the best way]
Let's say I have a DropDownList in my aspx page, and an enumeration (List of User types for example). I need to bind enum values to my dropdownlist.
Here is the solution
Note : In ToString("d")  d is a format parameter which return an integer when used with enum type;
In ToString("f")  f is also a format parameter which return flag when used with enum type

Hope it help someone ..... :-)

Download Demo website

0 comments:

Post a Comment