asp.net-mvc – 使用MVCContrib格式进行编辑

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 使用MVCContrib格式进行编辑前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我刚刚开始在测试项目中使用MVCContrib网格.我很难找到有关如何使用它进行编辑/更新/删除的信息.

任何人都可以指出有关如何将这一行置入编辑模式的信息,或者如果没有这样的事情,请讨论在MVC中编辑列表数据的最佳做法.

解决方法

看起来好像MVCContrib是从一个模型对象的集合中构建 HTML表的简单方法.似乎没有任何能力将一行放入与WebForms GridView相似的编辑/更新/删除“模式”中.

但是,它看起来像您可以处理该功能.如果要转到单独的页面进行编辑模式,只需在其中一列与该行的ID相关联.以下是直接从:http://www.jeremyskinner.co.uk/2009/03/01/mvccontrib-grid-part-5-the-action-syntax/

  1. <% Html.Grid(Model).Columns(column => {
  2. column.For(x => x.Id).Named("Person ID");
  3. column.For(x => x.Name);
  4. column.For(x => x.Gender);
  5. column.For(x => x.DateOfBirth);
  6. column.For("View Person").Named("").Action(p => { %>
  7. <td style="font-weight:bold">
  8. <%= Html.ActionLink("View Person","Show",new { id = p.Id })%>
  9. </td>
  10. <% });
  11. }).RowStart((p,row) => {
  12. if (row.IsAlternate) { %>
  13. <tr style="background-color:#CCDDCC">
  14. <% } else { %>
  15. <tr>
  16. <% }
  17. }).Render(); %>

在这里,他们希望将用户引导到View Person页面:<%= Html.ActionLink(“View Person”,“Show”,new {id = p.Id})%&gt ;. 祝你好运,快乐编码.

猜你在找的asp.Net相关文章