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>
}
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);
}
public ActionResult imgBtEdit_Click(int p_id)
{
return RedirectToAction("Insert", "Default", p_id);
}
How to know which checkbox is selected and how to get the datakeys?
Any suggestions or blogs?
Thank you
Swathi N