You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
@{
|
|
var list = new SelectList(new List<SelectListItem>());
|
|
var htmlClass = "form-control select search";
|
|
|
|
@if (!string.IsNullOrEmpty(ViewData.ModelMetadata.TemplateHint))
|
|
{
|
|
htmlClass += " " + ViewData.ModelMetadata.TemplateHint;
|
|
}
|
|
if (ViewData.ModelMetadata.IsEnum)
|
|
{
|
|
if (ViewData.ModelMetadata.IsNullableValueType)
|
|
{
|
|
var enumType = ViewData.ModelMetadata.ModelType.GetGenericArguments()[0];
|
|
var items=Enum.GetValues(enumType).Cast<Enum>()
|
|
.Select(o => new SelectListItem { Value = o.GetValue().ToString(), Text = o.GetDisplayName() })
|
|
.ToList();
|
|
list = new SelectList(items, "Value", "Text",(Model as Enum)?.GetValue().ToString());
|
|
}
|
|
else
|
|
{
|
|
list = (Model as Enum).GetSelectList();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ViewData.Get((Guid)Model) != null)
|
|
{
|
|
@ViewData.Get((Guid)Model)
|
|
}
|
|
}
|
|
<div>
|
|
@foreach (var item in list.Where(o => o.Selected))
|
|
{
|
|
<lable>@item.Text</lable>
|
|
}
|
|
</div>
|
|
} |