I am trying to learn MVC and have been stuck on this for quite some time, all the tutorial online uses strongly typed view but my view isn't strongly typed,
@using (Html.BeginForm("addInventory", "AdminController", FormMethod.Post))
{
<div class="form-style-2-heading">Add New Inventory</div>
<label>
<span>No <span class="required">*</span></span>@Html.TextBox("no", null, new { id = "no", Class = "input-field" })
</label>
<label>
<span>Name <span class="required">*</span></span>@Html.TextBox("name", null, new { id = "name", Class = "input-field" })
</label>
<label>
<span>Primary Type <span class="required">*</span></span>@Html.DropDownList("typeList", ViewBag.typeList as SelectList, new { id = "primarytype", Class = "select-field" })
</label>
<label>
<span>Secondary Type <span class="required">*</span></span>@Html.DropDownList("typeList", ViewBag.typeList as SelectList, new { id = "secondarytype", Class = "select-field"})
</label>
<label><span> </span><input type="submit" value="Submit" /></label>
}
So I successfully binded my dropdown list with data from the controller but I can't seem to do it the other way round
Edit:
Model:
public class inventoryModel
{
public int no { get; set; }
public string name { get; set; }
public int primaryType { get; set; }
public int secondaryType { get; set; }
}
Controller:
private ActionResult addInventory()
{
return View();
}