Generation and Population of values in DropdownList

Posted by Rasagna under ASP.NET MVC on 2/24/2016 | Points: 10 | Views : 280 | Status : [Member] | Replies : 0
I have a problem with generation of dropdownlist and populating it with values.I have a Model called GroupsModel written in AdminModel inherited from HeaderModel.
 public class GroupsModel : HeaderModel
public Guid Id { get; set; }
public String GroupName { get; set; }
public Guid GroupId { get; set; }
public IEnumerable<SelectListItem> GroupsList { get; set;

I have a view called groups.cshtml which uses groupsmodel and i also have a partialview _groupspartial where i need to generate a dropdown list which must populate Groupslist according to GroupId .
I have a controller to fetch groupslist in which i have written code as
public ActionResult GetGroups()
var groupsmodel = new GroupsModel();
var groupsList = new List<SelectListItem>();
groupsList = _adminSystemServices.GetGroups().ToList();
groupsList.Insert(0, new SelectListItem { Text = "Select Group", Value = "" });
groupsmodel.GroupsList = groupsList;
return PartialView("_MyGroupsPartial",groupsmodel);

Can anyone please help me with the dropdownlist generation.


(No response found.)

Login to post response