This is my Controller:
namespace OBBMS.Controllers
{
public class BDMController : Controller
{
public ActionResult Index()
{
OBBMS.Models.User objUser = new Models.User();
objUser.lstUser = DB_Interactions.BDMGetUsers("Pending");
return View(objUser);
}
[HttpPost]
public ActionResult Index(OBBMS.Models.User objUser)
{
return View();
}
}
}
Here is View Code:
@model OBBMS.Models.User
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_LayoutBloodDonationManagement.cshtml";
}
@using (Html.BeginForm("Index", "BDM", FormMethod.Post, new {id = "BDM"}))
{
<table id="mytable" class="table table-bordred table-striped">
<thead>
<tr>
@*<th>Post ID</th>*@
<th>Full Name</th>
<th>Blood Group</th>
<th>Email Address</th>
<th>Contact No</th>
<th>Address</th>
<th>Post Title</th>
</tr>
</thead>
<tbody>
@foreach(var obj in Model.lstUser)
{
<tr>
<td style="display:none!important;">@obj.PostID</td>
<td>@obj.FullName</td>
<td>@obj.BloodGroupName</td>
<td>@obj.EmailAddress</td>
<td>@obj.ContactNo</td>
<td>@obj.Address</td>
<td>@obj.PostTitle</td>
<td><input type="submit" value="Approve" class="btn btn-primary btn-xs" data-title="Approved" data-toggle="modal" data-target="#edit" /></td>
</tr>
}
</tbody></table>}
I have a submit button at the end of each row, I need to get Single instance of User object instead of complete list in HttpPost ActionResult Method when a specific row button is click. I just need to get the object only the row button is clicked.
If possible: I do not want to use any JavaScript/jQuery/Ajax, everything should be done in APS.NET MVC framework.
If not possible: Suggest me best and easiest way to do it.
<form>and you do not have any form controls so there is nothing to submit. Are you wanting to update the status (to approved) of an record in your collection?<form>tag inside<td>tag targeting yourEditaction in your submit button setting your user-id as key parameter to send. Then manage it in yourEditaction.