Hi ALL, I am binding my dropdownlist with Enum I have following enum and code for bind dropdownlist.
public enum DignosisOrderType
{
All = 0,
General = 1,
Uveitis = 2,
Coag =3,
PreOp=4,
Tests=5,
RP =6
}
public static void BindDropDownByEnum(DropDownList dropDownList, Type enumDataSource, )
{
Hashtable htDataSource = new Hashtable();
string[] names = Enum.GetNames(enumDataSource);
Array values = Enum.GetValues(enumDataSource);
for (int i = 0; i < names.Length; i++)
htDataSource.Add(names[i], values.GetValue(i));
BindDropDown(dropDownList, htDataSource, "key", "value");
}
public static void BindDropDown(DropDownList dropDownList, object dataSource, string dataTextField, string dataValueField)
{
dropDownList.DataSource = dataSource;
dropDownList.DataTextField = dataTextField;
dropDownList.DataValueField = dataValueField;
dropDownList.DataBind();
}
when the Dropdownlist is bind the data is not comming in sorting order,I want dropdownlist is bind in order of Enum is created.