Hi I have created a table and connected it to MVC project through ADO.NET entity. After connecting I added the controller for the entity and it creates a set of cshtml file
Firstly, let's create a View Model to hold these things:
public class PlanViewModel
{
public List Plans { get; set; }
}
Then, in your controller action let's build the Model:
public ActionResult Index()
{
var model = new PlanViewModel();
model.Plans = db.Plan_S
.Select(p => new SelectListItem
{
Value = p.Hours,
Text = p.PlanNames
})
.ToList();
return View(model);
}
Then in your View, do:
@model Pivot.Models.Plan_S
@{
ViewBag.Title = "Index";
}
Index
@Html.DropDownList("PlanNames", Model.Plans, "--select--")
Then you'll need to do the following in jQuery: