Html.Grid 中的复选框回发
我有一个由 IList: 组成的网格:
@Html.Grid(Model.ExampleList).Columns(c =>
{
c.For(a => string.Format("{0:dd/MM/yyyy}", a.DateRequested)).Named("Date Requested");
c.For(a => a.Comment).Named("Comment");
})
但我想添加一个复选框,它将回发到控制器。与此类似的东西:
@using (Html.BeginForm("PostExample", "Home"))
{
<input type="hidden" name="SomeId" [email protected]/>
<input type="hidden" name="AnotherId" value="AnotherId" />
@Html.CheckBox("Complete", Model.Complete, new { onClick = "$(this).parent('form:first').submit();"
});
但我不确定如何将它们结合起来。这样做的最佳方法是什么?任何帮助将不胜感激。
I have a grid which is by an IList:
@Html.Grid(Model.ExampleList).Columns(c =>
{
c.For(a => string.Format("{0:dd/MM/yyyy}", a.DateRequested)).Named("Date Requested");
c.For(a => a.Comment).Named("Comment");
})
But i'd like to add a checkbox which would Post back to a controller. Something similar to this:
@using (Html.BeginForm("PostExample", "Home"))
{
<input type="hidden" name="SomeId" [email protected]/>
<input type="hidden" name="AnotherId" value="AnotherId" />
@Html.CheckBox("Complete", Model.Complete, new { onClick = "$(this).parent('form:first').submit();"
});
But I'm not sure how to combine them. What is the best way of doing this? Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题很不清楚。您想在哪里显示此复选框?每行?取决于模型的某些值?如果是,那么您可以使用自定义列,如下所示:
Your question is very unclear. Where do you want to show this checkbox? On each row? Dependent on some value of your model? If yes, then you could use a custom column, like this: