OK, I\'ve been Googling for hours and trying everything and can\'t get anything to work. I am learning MVC using Sharp Architecture and have generated some basic forms for c
This is View - MVC Controller
@Html.DropDownListFor(m => m.Entity, new ABC.Models.DropDownPopulate().MyMethod, new { @class = "form-control input-inline input-medium" })
MyMethod Get Data List Bind With Dropdown Using SelectListItems
public List MyMethod
{
get
{
List dropdownList = new List();
var items = new DropDown_Bl().GetAll();
foreach (var item in items)
{
SelectListItem dropdownItem = new SelectListItem();
dropdownItem.Value = item.RnID.ToString();
dropdownItem.Text = item.Description;
dropdownList.Add(dropdownItem);
}
dropdownList.Insert(0, new SelectListItem() { Text = "Please Select", Value = "", Selected = true });
return dropdownList;
}
}
GetAll Method In Dropdown_Bl - Used to get data as list from database
public List GetAll()
{
var Items = _Context.MyRepository.GetMany(q => q.Area == "ASD").ToList();
return Items ;
}