How to Get Dropdownlist value in mvc
<div class="form-group">
@Html.LabelFor(model => model.Status, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@{
List<SelectListItem> listItems = new List<SelectListItem>();
listItems.Add(new SelectListItem
{
Text = "Active",
Value = "1"
});
listItems.Add(new SelectListItem
{
Text = "No-Active",
Value = "2"
});
}
@Html.DropDownList("ddlstatus", new SelectList(listItems, "Value", "Text"))
@Html.ValidationMessageFor(model => model.Status, "", new { @class = "text-danger" })
</div>
</div>
Controller code--
public ActionResult Category(tbl_Category category, int ddlstatus) {
tbl_Category categry = new tbl_Category();
categry.Status = ddlstatus;
DB.tbl_Category.Add(categry); DB.SaveChanges();
}
i am not able to get text of selected dropdown item