我在列表集合中添加和删除项目时遇到了一些麻烦。我使用 MVC 4,剃刀。
找到了一些例子,但它基于jquery和javascript - MVC不能单独做吗?我想添加建筑物和建筑物的一些楼层 - 并再次删除项目。
房子.cs
public class House
{
public House()
{
Buildings = new List<HouseBuilding>();
}
public List<HouseBuilding> Buildings { get; set; }
public String Address { get; set; }
public String RoofType { get; set; }
}
房屋建筑.cs
public class HouseBuilding
{
public HouseBuilding()
{
Floors = new List<HouseBuildingFloor>();
}
public List<HouseBuildingFloor> Floors { get; set; }
public Int32 BuildingNo { get; set; }
public Int32 SquareMeters { get; set; }
public Boolean Deleted { get; set; }
public String DeletedClass
{
get
{
if (Deleted)
{
return "containerHidden";
}
else
{
return "containerVisible";
}
}
}
}
HouseBuildingFloor.cs
public class HouseBuilding
{
public HouseBuilding()
{
Floors = new List<HouseBuildingFloor>();
}
public List<HouseBuildingFloor> Floors { get; set; }
public Int32 BuildingNo { get; set; }
public Int32 SquareMeters { get; set; }
public Boolean Deleted { get; set; }
public String DeletedClass
{
get
{
if (Deleted)
{
return "containerHidden";
}
else
{
return "containerVisible";
}
}
}
}