If you want to have a select list in a web page which is based on all the values in an enum then you can use the built in function “Html.GetEnumSelectList” with a tag helper.

public enum PushType
{
	Notification,
	Image,
	Action
}
<div class="row">
	<div class="col-sm-2">
		<label asp-for="@Model.Data.Type" class="control-label text-left"/>
	</div>
	<div class="col-sm-10">
		<select asp-for="@Model.Data.Type" asp-items="Html.GetEnumSelectList<PushType>()" class="form-control" required="required">
			<option selected="selected" value="" disabled>--Please Select--< option>
		</select>
		<div class="help-block with-errors"/>
	</div>
</div>

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *