mvc3复选框选中了Web网格中的行 [英] mvc3 checkbox checked rows in the web grid

查看:71
本文介绍了mvc3复选框选中了Web网格中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请帮助我了解MVC3中Webgrid中选中的复选框.

在此先感谢
Pavan

Hi All,

Please help me out in knowing the selected checkboxes in the webgrid in MVC3.

Thanks in Advance
Pavan

推荐答案

1.确保您的WebGrid包裹在表单内.

1. Ensure that your webgrid is wrapped inside a form.

@using (Html.BeginForm("Assign","Home"))
  {
  }



在webgrid列中,添加一个带有复选框的列,如下所示,我想您已经拥有了.




In the webgrid columns add a column with check box as follows which I think already you have.


grid.Column(header: "Assign?", format: @<text><input class="check-box"  id="assignChkBx"name="assignChkBx" type="checkbox" value="@item.Id"/></text>)




2.在控制器检索"中,使用id值检查的对象如下::




2. At Controller Retrieve objects that are checked using id values as follows::

[HttpPost]
        public ActionResult Assign(FormCollection form)
        {
            var ch = form.GetValues("assignChkBx");
            foreach (var id in ch)
            {
              //...Get object using id
              //...Call your method
            }
            return View();
        }




这可能对您有帮助

http://stackoverflow.com/questions/5418957/mvc-3-webgrid- with-a-checkbox-filter [ ^ ]

http://weblogs.asp.net/imranbaloch/archive/2011/09/13/webgrid-helper-with-check-all-checkboxes.aspx [ http://stackoverflow. com/questions/6951015/multiple-checkbox-selection-using-webgrid-in-mvc-3-select-all-deselect-all-so [
Hi

This may be help you

http://stackoverflow.com/questions/5418957/mvc-3-webgrid-with-a-checkbox-filter[^]

http://weblogs.asp.net/imranbaloch/archive/2011/09/13/webgrid-helper-with-check-all-checkboxes.aspx[^]

http://stackoverflow.com/questions/6951015/multiple-checkbox-selection-using-webgrid-in-mvc-3-select-all-deselect-all-so[^]

thanx


这篇关于mvc3复选框选中了Web网格中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆