【发布时间】:2011-11-04 03:10:12
【问题描述】:
希望这会有一个简单的答案。
使用 MVC3,我将一个简单的 POCO 对象列表作为模型传递给我的视图:
public partial class PeopleAddress
{
public int Id { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public int PersonId { get; set; }
public virtual Person Person { get; set; }
}
我使用 PeopleId 作为 Person 实体的 FK 属性,并使用 Person 导航属性导航到对象。这是我的视图控制器:
public ViewResult Index()
{
var peopleaddresses = db.PeopleAddresses.Include("Person");
return View(peopleaddresses.ToList());
}
相当琐碎。我将列添加到视图中的网格和普通编辑模式等,但对于 PersonId 属性。
关于列的问题:如何获得选择(正常)模式来显示 model.Person.Name,但在编辑 model.PersonId 时保持编辑模式?出于模型绑定的目的,我需要 HTTP 帖子来发送 PersonId。
救命!
【问题讨论】:
标签: model-view-controller asp.net-mvc-3 telerik telerik-grid telerik-mvc