我遇到的问题是view
不允许我显示全部信息。
WorseningParameter Class
public class MatrixWorseningParameter
{
[Key]
public int worseningParameterID { get; set; }
public int paramID { get; set; }
public int paramID2 { get; set; }
public virtual MatrixParameter MatrixParameters { get; set; }
public virtual ICollection<MatrixWorseningPrinciple> MatrixWorseningPrinciples { get; set; }
}
参数类
public class MatrixWorseningParameter
{
[Key]
public int worseningParameterID { get; set; }
[Display(Name = "Main Parameter")]
public int paramID { get; set; }
[Display(Name = "Worsening Parameter")]
public int paramID2 { get; set; }
public virtual MatrixParameter MatrixParameters { get; set; }
public virtual ICollection<MatrixWorseningPrinciple> MatrixWorseningPrinciples { get; set; }
}
查看
@model Main.Models.Matrix.MatrixParameter
<tbody>
@foreach (var item in Model.MatrixWorseningParameters)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.paramID2)
@Html.DisplayFor(modelItem => item.MatrixParameters.fullParam)
</td>
<td></td>
<td>
@Html.ActionLink("Add", "../MatrixWorseningParameters/Create", new { id = Model.paramID })
</td>
</tr>
}
</tbody>
控制器
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
MatrixWorseningParameter matrixWorseningParameter = db.WorseningParameters.Find(id);
if (matrixWorseningParameter == null)
{
return HttpNotFound();
}
return View(matrixWorseningParameter);
}
我在视图上看到的结果是显示正确的paramID2
数字,但遗憾的是,引用paramID
的文字不正确。它显示paramID
。
我该怎么做才能克服这个问题?
答案 0 :(得分:1)
你可以在下面添加另一个DisplayFor
说明,因为你说你的condition
类是product
的孩子,因此它将包含product
中定义的所有属性。 1}}类(Title
,Description
,Date
)
@Html.DisplayFor(model => item.Title)