Error :
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Holiday_approve(Int32)' in 'layout_wise_minicrm.Controllers.holiday_scheduleController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
[HttpGet]
public ActionResult Holiday_approve()
{
ViewBag.applholiday = crm.manual_holiday.ToList();
return View();
}
[HttpPost]
public ActionResult Holiday_approve(int id)
{
ViewBag.applholiday = crm.manual_holiday.ToList();
var details = crm.manual_holiday.SingleOrDefault(m => m.Id == id);
details.Approved_status = true;
crm.SaveChanges();
return RedirectToAction("Holiday_approve");
}
What I have tried:
i have been change into routeconfig as well as action parameters (int? id) but still not resolved issue.. and did ajax jquery code for fetch id ..
view code:
<input type="submit" id="btnapprove" onclick="holidayapprove(@data.Id);">
function holidayapprove(Id) {
$.ajax({
type: "POST",
url: '@Url.Action("Holiday_approve", "holiday_schedule")',
cache: false,
data: { Id:Id},
success: function (result) {
},
failure: function (result) {
alert("Server Error");
}
});
}