![](/img/trans.png)
[英]How can I have DropDownList in each and every cell of the GridView when the headers of the GridView are Unknown
[英]Can I have one DisplayName for data entry and the Column Headers in a gridview?
顯示數據時,是否可以使用標題中的[DisplayName("My descriptive Name")]
和僅使用列名?
(不必鍵入每個字母嗎?)-(我使用MVC腳手架來創建編輯頁面)
<p>
@Html.ActionLink("Create New", "CreateTask")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
</tr>
<td>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
</tr>
}
</table>
像這樣在模型中添加屬性顯示
[Display(Name = "Your Custom Name")]
public string Name { get; set; }
並在Razor View中使用
@Html.LabelFor(model=>model.Name)
希望這對您有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.