Answers for "Html.DropDownListFor() in Razor View"

C#
0

Html.DropDownListFor() in Razor View

@using MyMVCApp.Models

@model Student

@Html.DropDownListFor(m => m.StudentGender, 
            new SelectList(Enum.GetValues(typeof(Gender))), 
            "Select Gender")


//upon compilations
<select class="form-control" id="StudentGender" name="StudentGender">
    <option>Select Gender</option> 
    <option>Male</option> 
    <option>Female</option> 
</select>
Posted by: Guest on September-28-2021

C# Answers by Framework

Browse Popular Code Answers by Language