意图:
基本上,我希望在通过Data-Annotations
生成的模型类中使用Entity Framework-6.1.3
使特定的列不可编辑,我已经尝试过:
//model class
[ReadOnly(true)]
public int DepID { get; set; }
名为DepID
的上述列是此模型类中的Foreign-key
。
问题:
我不知道这有什么问题。字段值不显示为readonly
。
发布于 2015-12-21 11:43:36
真的有必要展示DepID吗?我建议您将DepID作为@Html.HiddenFor(m => m.DepID)
传递到您的表单中。这样,当您将数据发送回服务器时,属性仍然存在。
https://stackoverflow.com/questions/34391266
复制相似问题