public class CreateProjeModel
{
public Proje Proje { get; set; }
public List<GeometryModel> GeometryList { get; set; }
public CreateProjeModel()
{
Proje = new Proje();
GeometryList = new List<GeometryModel>();
}
}
public class GeometryModel
{
public List<PointModel> PointList { get; set; }
public GeometryModel()
{
PointList = new List<PointModel>();
}
}
public class PointModel
{
public int X { get; set; }
public int Y { get; set; }
}
public class Proje : EntityBase
{
public int FirmaId { get; set; }
public int IlId { get; set; }
public int? IlceId { get; set; }
public int PlanTurId { get; set; }
public int EtudTurId { get; set; }
public int EtudAmacId { get; set; }
public int DilimId { get; set; }
public string Aciklama { get; set; }
public virtual Firma Firma { get; set; }
public virtual IL Il { get; set; }
public virtual ILCE Ilce { get; set; }
public virtual PlanTur PlanTur { get; set; }
public virtual EtudTur EtudTur { get; set; }
public virtual EtudAmac EtudAmac { get; set; }
public virtual Dilim Dilim { get; set; }
}
我有一个名为CreateProjeModel的复杂模型。我正在使用'for'循环集合属性和绑定,如下所示:
@Html.TextBoxFor(m => m.GeometryList[i].PointList[j].X)
行动如下:
[HttpPost]
public async Task<ActionResult> Create(CreateProjeModel proje)
{
//ToDo
return View(proje);
}
发布数据如下:
当涉及到动作时,GeometryList为空,并且Proje的属性未设置为发布值。我在哪里做错了?
答案 0 :(得分:1)
您的问题是,您的CreateProjeModel
模型有一个名为Proje
的属性,但Create()
方法的参数也被命名为proje
。您需要将方法签名更改为(比如)
public async Task<ActionResult> Create(CreateProjeModel model)
其中参数名称与您的某个属性的nae不同