First Create enum
public enum test
{
[Description("test1")]
test1= 0,
[Description("test2")]
test= 1 ,
[Description("test3")]
test= 2 ,
[Description("test4")]
test= 3
}
Assign Enum value to view
@Html.DropDownList("test", (from test in Enum.GetValues(typeof(test))
select new SelectListItem { Value = ((int)test).ToString(), Text = test.GetDescription() }))
public enum test
{
[Description("test1")]
test1= 0,
[Description("test2")]
test= 1 ,
[Description("test3")]
test= 2 ,
[Description("test4")]
test= 3
}
Assign Enum value to view
@Html.DropDownList("test", (from test in Enum.GetValues(typeof(test))
select new SelectListItem { Value = ((int)test).ToString(), Text = test.GetDescription() }))
Simple example , its working fine. :)
ReplyDelete