User364607740 posted
I have a model class,
namespace myapp.Models
{
public class SchoolModels
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
public int ShoolType { get; set; }
}
}
In Create.cshtml page, I have created a static drop down list to select the value for
ShoolType attribute.
@Html.DropDownList("ShoolType", new List<SelectListItem>
{
new SelectListItem {Text = "community", Value = "1"},
new SelectListItem {Text = "boarding", Value = "2"},
new SelectListItem {Text = "others", Value = "3"}
}, "select shool type")
But in Index.cshtml page, I am getting the integer values for ShoolType. How can I display the
ShoolType as community for 1, boarding for 2 and others for 3?
public ActionResult Index()
{
return View(db.Schools.ToList());
}