你好我试图编辑/添加我的复杂模型,我有一个问题,我的模型:
public partial class NodeLoc
{
public int NodeId { get; set; }
public string Title { get; set; }
public string Brief { get; set; }
public string Details { get; set; }
public virtual Node Node { get; set; }
}
public partial class Node
{
public int NodeId { get; set; }
public int TypeId { get; set; }
public Nullable<int> CatId { get; set; }
public Nullable<int> AlbumId { get; set; }
public System.DateTime PostDate { get; set; }
public string ImageUrl { get; set; }
}
我的控制器
[HttpPost]
public ActionResult Create(NodeLoc entity, int typeId, HttpPostedFileBase ImageUrl)
{
ModelState.Remove("NodeId");
if (ModelState.IsValid)
{
Node node = entity.Node;
node.TypeId = typeId;
node.CatId = entity.Node.CatId; //cant read
node.AlbumId = entity.Node.AlbumId; //cant read
node.PostDate = DateTime.Now;
node.ImageUrl = ImageResizer.SaveImage("Uploads/Node", ImageUrl);
db.Nodes.Add(node);
db.NodeLocs.Add(entity);
db.SaveChanges();
return RedirectToAction("Create", new { isSuccess = true, typeId = typeId });
}
return View(entity);
}
和我的观点
@model MvcCms.Models.NodeLoc
@Html.HiddenFor(model => model.NodeId)
@Html.HiddenFor(model => model.Node.CatId)
@Html.HiddenFor(model => model.Node.AlbumId)
我的问题是:在帖子中我无法读取此值:model.Node.CatId或model.Node.AlbumId