View:
<select multiple="" id="e2" tabindex="-1" class="select2-hidden-accessible" name="e2" aria-hidden="true">
<option value="PDS.RICE">PDS.RICE</option>
<option value="PDS.WHEAT">PDS.WHEAT</option>
<option value="PDS.DAL CHANNA">PDS.DAL CHANNA</option>
<option value="PDS.DAL KALA CHANNA">PDS.DAL KALA CHANNA</option>
</select>
Controller:
public ActionResult Getitems()
{
var items = (from m in db.ItemMasters select m).ToList();
ViewBag.items = items;
return View();
}
Model:
public class ItemMaster
{
[Key]
public int ItemId { get; set; }
public string Item_Name { get; set; }
}
I am trying to fetch the data from database in the controller, but unable to bind the ViewBag data to the select2-hidden-accessible in view.
@Html.DropDownListFor()and strongly bind to a model?