我刚刚开始在测试项目中使用MVCContrib网格.我很难找到有关如何使用它进行编辑/更新/删除的信息.
任何人都可以指出有关如何将这一行置入编辑模式的信息,或者如果没有这样的事情,请讨论在MVC中编辑列表数据的最佳做法.
解决方法
看起来好像MVCContrib是从一个模型对象的集合中构建
HTML表的简单方法.似乎没有任何能力将一行放入与WebForms GridView相似的编辑/更新/删除“模式”中.
但是,它看起来像您可以处理该功能.如果要转到单独的页面进行编辑模式,只需在其中一列与该行的ID相关联.以下是直接从:http://www.jeremyskinner.co.uk/2009/03/01/mvccontrib-grid-part-5-the-action-syntax/
- <% Html.Grid(Model).Columns(column => {
- column.For(x => x.Id).Named("Person ID");
- column.For(x => x.Name);
- column.For(x => x.Gender);
- column.For(x => x.DateOfBirth);
- column.For("View Person").Named("").Action(p => { %>
- <td style="font-weight:bold">
- <%= Html.ActionLink("View Person","Show",new { id = p.Id })%>
- </td>
- <% });
- }).RowStart((p,row) => {
- if (row.IsAlternate) { %>
- <tr style="background-color:#CCDDCC">
- <% } else { %>
- <tr>
- <% }
- }).Render(); %>
在这里,他们希望将用户引导到View Person页面:<%= Html.ActionLink(“View Person”,“Show”,new {id = p.Id})%> ;. 祝你好运,快乐编码.