表格标签不显示

时间:2011-04-05 09:53:41

标签: asp.net-mvc asp.net-mvc-3

使用asp.net mvccontrib网格。使用自定义列时,不会显示表单标记:

@(Html.Grid<SomeModelType>(Model.PagedList)
  .Columns(columns => 
  {
      columns.Custom(
          @<text>
               @using(Html.BeginForm("DeleteAction", "Controller", new { Id=@item.UserId}))
               {
                   <input type="submit" value="Delete" />
               }
           </text>
      );
  })
  .Sort(Model.GridSortOptions)
)

它在列中输出:<input type="submit" value="Delete" />

2 个答案:

答案 0 :(得分:0)

为什么要使用@<text> </text>

答案 1 :(得分:0)

试试这样:

@(Html
    .Grid<MyViewModel>(Model)
    .Columns(columns => 
    {
        columns.Custom(model => Html.Partial("_DeleteLink", model));
    })
    .Sort(Model.GridSortOptions)
)

并在_DeleteLink.cshtml部分内:

@model SomeModelType
@using(Html.BeginForm("DeleteAction", "Controller", new { id = Model.UserId }))
{
    <input type="submit" value="Delete" />
}