Hi
In Controller how i can track whether it is Update or Add
@Html.DisplayNameFor(model => model.Id) | @Html.DisplayNameFor(model => model.Description) | @Html.DisplayNameFor(model => model.IsActive) | Action |
|---|---|---|---|
@Html.DisplayFor(modelItem => item.Id) | @Html.DisplayFor(modelItem => item.Description) | @Html.DisplayFor(modelItem => item.IsActive) | Edit @if (item.IsActive) |
@using (Html.BeginForm("CreateEdit", "Location", FormMethod.Post))
{
}
**********************************************
[HttpPost]
public ActionResult CreateEdit(Location objLocation)
{
if (ModelState.IsValid)
{
dbLocation.Add(objLocation);
//return Json(new { success = true, message = "Successfully Saved" });
}
return RedirectToAction("Index");
}
Thanks
Rajendran SPosted Jun 8, 2021, 4:57 PM
Ramco RamcoPosted Jun 8, 2021, 3:57 PM
Sachin SinghPosted Jun 8, 2021, 3:37 PM
Ramco RamcoPosted Jun 8, 2021, 1:31 PM
Hi Sachin/Salman
I have belwo function on btnEdit click.
Suppose Id value is AA. How i can append U to Id means UAA. Then in Controller how i should remove 1st character "U" from Id & save with the remaining Value .
Is there any other best option possible.
$('body').on('click', '[id*=btnEdit]', function () {
var data = $(this).parents('tr').find('td');
var Id = data.eq(0).html();
var Description = data.eq(1).html();
var IsActive = data.eq(2).html();
$('[id*=txtId]').val(Id);
$('[id*=txtDescription]').val(Description);
$('[id*=txtISActive]').val(IsActive);
$(".modal-title").html("Update");
//$('#myModal').modal("show");
});
Thanks
Salman BegPosted Jun 8, 2021, 1:09 PM
Sachin SinghPosted Jun 8, 2021, 1:06 PM