Guest User

Guest User

  • Tech Writer
  • 611
  • 129.3k

face a null value.

Nov 26 2020 12:36 AM
I have use this code for delete multiple entry on button click.But i have face null value(Id).Please check this code
It's me jquery code
function confirmDelete() {
debugger;
var EducationalId = [];
$(".chk:checked").each(function (i, y) {
debugger;
EducationalId.push($(this).val());
});
swal({
title: "Confirmation?",
text: "Are you sure you want to delete record?",
type: "warning",
confirmButtonClass: "btn-danger",
showCancelButton: true,
confirmButtonText: "Yes",
closeOnConfirm: false
},
function (isConfirm) {
if (!isConfirm) return;
$.ajax({
url: "DeleteImageData",
type: "POST",
data: JSON.stringify(EducationalId),
contentType: 'application/json; charset=utf-8',
datatype: 'json',
success: function () {
swal({
title: "Done", text: "Image deleted successfully",
type: "success"
}, function () {
location.reload();
});
},
error: function (xhr, ajaxOptions, thrownError) {
swal("Error deleting!", "Please try again", "error");
}
});
});
};
it's me mvc code  public IActionResult DeleteImageData(int[] EducationalId) Here we have face a issue (Id is 0)
it's me button click 
<button type="submit" class="btn btn-danger btndelete" onclick="confirmDelete()" id="@Model.EducationalId"><i class="fa fa-trash"></i> Delete</button>
 
 
Please check this
 

Answers (5)