在视图中编辑页面或索引.MVC中的cshtml



我在我的应用程序中使用MVC 5和实体框架6(数据库第一)。我需要更新"值"字段在视图页index.cshtml。是否可以使用@Html。编辑器编辑值字段为每个项目在单个按钮单击?下面是index.cshtml

中的代码
<table>
 <tr>
        <th>
            Number
        </th>
        <th>
            Name
        </th>
        <th>
            Value
        </th>
        <th>
            Description
        </th>     
    </tr>
     foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.number)                
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.name)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.value)
             @*@Html.ValidationMessageFor(modelItem => item.value) *@       
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.description)
            </td>
  @* <td>
       @Html.ActionLink("Edit", "Edit", new { id=item.id })      
    </td>*@
</tr>
</table>
<div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Save" class="btn btn-default" />          
        </div>
</div>
在单击Save按钮时,我应该更新Value字段中的任何行数的数据。它是在Database First中完成的,所以Edit,View,Details的动作包含在Controller中

您必须将所有内容放入a中以将详细信息发布到服务器,然后您可以管理发布的元素。你要贴一张物品清单。也许这将帮助你:我怎么能张贴项目列表在MVC

最新更新