Did anyone ever manage to create forms within the grid?
Attempt (which does not work):
<%= Html.Grid(ViewData["xyz"] as IEnumerable<xyz>).Columns(column =>
{
column.For(gf => gf.Value).Named("Value");
column.For(gf =>
<% using (Html.BeginForm("deletebla", "controllername", FormMethod.Post, new { @class = "deleteForm" }))
{ %>
<input type="submit" value="Delete" />
<% }
%>
).Named("");
}).Empty("Sorry no data.")%>
Thanks.
Chris
Two possibilities here (in my example I will be using a strongly typed view instead of
ViewDatain order to promote good practice).Use the Action Syntax:
after adding this in web.config to make sure that proper extension methods are in scope:
Or if you want to avoid the tag soup simply use a partial:
And in
Foo.ascx:I would definitely choose the second option.