Drop down using an enumerator as the datsource.
//Assuming an Enum is defined elsewhere as
public enum PriorityType { VeryLow = 1, Low = 2, Medium = 3, High = 4, VeryHigh = 5 };
//Can hook up names to a List Control
ddlPriorityType.DataSource = Enum.GetNames(typeof(PriorityType));
//Can set value of List Control
ddlPriorityType.SelectedItem = Enum.GetName(typeof(PriorityType), product.PriorityType);
//Can then get the selected value using the parse method and casting the result as an int
((int)Enum.Parse(typeof(PriorityType), ddlPriorityType.SelectedItem.ToString(), true)).ToString();
//Assuming an Enum is defined elsewhere as
public enum PriorityType { VeryLow = 1, Low = 2, Medium = 3, High = 4, VeryHigh = 5 };
//Can hook up names to a List Control
ddlPriorityType.DataSource = Enum.GetNames(typeof(PriorityType));
//Can set value of List Control
ddlPriorityType.SelectedItem = Enum.GetName(typeof(PriorityType), product.PriorityType);
//Can then get the selected value using the parse method and casting the result as an int
((int)Enum.Parse(typeof(PriorityType), ddlPriorityType.SelectedItem.ToString(), true)).ToString();
No comments:
Post a Comment