使用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" />
。
答案 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" />
}