无法获取GridView MVC4中所选复选框的ID [英] unable to get the id of selected checkbox in gridview MVC4

查看:70
本文介绍了无法获取GridView MVC4中所选复选框的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用MVC4中的这些功能实现Grid的插入,编辑,删除,过滤,排序,搜索.

我无法在gridview中获取所选复选框的ID.

Hi All,

I am trying to implement a Grid with these functionalities insert, edit,delete,Filter,sort,search in MVC4.

I am unable to get the id of selected checkbox in gridview.

@using (Html.BeginForm("GridIndex", "Grid", FormMethod.Get, new { id = "detailForm" }))
    {
        <div>
            <table style="background-color: #ddeeee; width: 100%; padding: 4px; border-collapse: separate; border-spacing: 1px">
                <tr style="background-color: white">
                    <td>
                        <input id="inputcheckInsert" type="image" src="~/App_Themes/Default/Images/insert.jpg" />
                        @using (Html.BeginForm("GridIndex", "Grid", FormMethod.Get, new { id = "InsertForm" }))
                        {    @Html.AntiForgeryToken()


                        }
                    </td>
                    <td>
                        @using (Html.BeginForm("GridIndex", "Grid", FormMethod.Get, new { id = "click" }))
                        { 
                            @Html.AntiForgeryToken()
                            <input id="inputInsert" type="image" src="~/App_Themes/Default/Images/insert.jpg" />
                        }
                    </td>
                    <td>
                        @using (Html.BeginForm("Insert", "Grid", FormMethod.Post, new { id = "click" }))
                        { 
                            @Html.AntiForgeryToken()
                            <input id="inputEdit" type="image" src="~/App_Themes/Default/Images/Edit.jpg" />
                        }
                    </td>
                    <td>
                        @using (Html.BeginForm("Insert", "Grid", FormMethod.Post, new { id = "click" }))
                        { 
                            @Html.AntiForgeryToken()
                            <input id="inputDelete" type="image" src="~/App_Themes/Default/Images/Delete.jpg" />
                        }
                    </td>
                    <td colspan="2"></td>
                </tr>
                @*<tr>
                    <td>
                        <input id="inputInsert" type="image" src="~/App_Themes/Default/Images/insert.jpg" />
                    </td>
                </tr>*@
                <tr style="background-color: #00647C; color: White; text-align: center;">
                    <td></td>
                    <td>Person Code
                    </td>
                    <td>First Name
                    </td>
                    <td>Last Name
                    </td>
                    <td>Person Status Id
                    </td>
                    <td>Email
                    </td>
                </tr>
                @foreach (MVCSampleApplication.BusinessServiceReference.ExternalPersonBE external in Model)
                {                                
                    <tr style="background-color: white">
                        <td>
                            @Html.CheckBox("chBx")
                        </td>
                        <td>
                            @external.m_personCode
                        </td>
                        <td>
                            @external.m_firstName
                        </td>
                        <td>
                            @external.m_lastName
                        </td>
                        <td>
                            @external.m_lnPersonStatusId
                        </td>
                        <td>
                            @external.m_eMail
                        </td>
                    </tr>        
                }
            </table>
        </div>
    }

// contrler class

 public ActionResult GridIndex(FormCollection collection)
        {
            BusinessServiceReference.BusinessServiceClient service = new BusinessServiceReference.BusinessServiceClient();
            BusinessServiceReference.PersonBE[] PersonBeList = service.GetPersonList(0, 0, string.Empty, string.Empty);


            return View(externalPersonBeList);
        }

//when check box is selected and clicked edit button, I need corresponding column Id //to be passed to click event

public ActionResult imgBtEdit_Click(int p_id)
        {
            return RedirectToAction("Insert", "Default", p_id);
        }



如何知道选中了哪个复选框,以及如何获取数据键?

有任何建议或博客吗?


谢谢
Swathi N



How to know which checkbox is selected and how to get the datakeys?

Any suggestions or blogs?


Thank you
Swathi N

推荐答案

您需要为复选框提供唯一的值,或者使用jquery根据可搜索的父节点进行过滤,以查找选中的父节点.
You need to give your checkboxes unique values or use jquery to filter based on a searchable parent node, to find which one is checked.


这篇关于无法获取GridView MVC4中所选复选框的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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