我在列表集合中添加和删除项目时遇到了一些麻烦。我使用MVC 4,Razor。
找到了一些例子,但它基于jquery和javascript - MVC不能单独做吗? 我想在建筑物上添加建筑物和一些楼层 - 并且还要再次移除物品。
House.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; }
}
HouseBuilding.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";
}
}
}
}