0
我想從Model中獲取項目列表以查看,但我沒有得到該確切想法 請幫助我 我正在添加我的所有類MVC如何傳遞模型中的對象列表並綁定查看Cshtml
下面
public class DivisionDTO
{
public Guid Id { get; set; }
public string Name { get; set; }
public List<GroupDTO> Groups { get; set; }
}
public class GroupDTO
{
public Guid Id { get; set; }
public string Name { get; set; }
public List<Team> Teams { get; set; }
}
public class Team
{
public int ID { get; set; }
public string TeamName { get; set; }
public int GroupId { get; set; }
public int DivisionId { get; set; }
public string pld { get; set; }
public string W { get; set; }
public string D { get; set; }
public string L { get; set; }
public string GF { get; set; }
public string GA { get; set; }
public string GD { get; set; }
public string Pts { get; set; }
}
模型本身是一個項目列表,每個項目包含子項目的名單。 在DivisionDTO類列表GroupDTO價值是存在的,在GroupDTO一流團隊價值是有
我控制器以下
public ActionResult EditGroup()
{
CreatingLeague.Models.DivisionDTO division = new CreatingLeague.Models.DivisionDTO();
division.Id = new Guid();
division.Name = "Div";
division.Groups = new List<CreatingLeague.Models.GroupDTO>();
CreatingLeague.Models.Team team = new Models.Team();
team.TeamName = "TeamA";
division.Groups.Add(new CreatingLeague.Models.GroupDTO() { Id = new Guid(), Name = "G1", Teams = new List<Team>() { team } });
return View(division);
}
我想打一個編輯頁面任何一個可以給我
的想法碼