jeudi 9 novembre 2023

Asp.Net Core , Checkbox is returning NULL value

I have a checkbox in my view to get the details about my 'Hall' entity class, and I have a view related to it, but my checkbox always return NULL value to entity class.

I tried others solutions but I can't solve and couldn't figure it out. Here's my codes

Hall.cs (entity class)

 public class Hall : BaseEntity, IAuditableEntity
 {
     [Key]
     public int Id { get; set; }
     public string Name { get; set; }
     public string? Description { get; set; }
     public string UpHall { get; set; }
     public bool IsUpHall { get; set; }
     public int Order { get; set; }
 }`
HallController.cs 

public class HallController : Controller
{
    private readonly IHallService _hallService;
    public HallController( IHallService hallService )
    {
        _hallService = hallService;
    }

    public IActionResult Index()
    {
        var values=_hallService.GetListAll();
        return View(values);
    }
    [HttpGet]
    public IActionResult AddHall()
    {
        return View();
    }
    [HttpPost]
    public async Task<IActionResult> AddHall(Hall hall )
    {
        _hallService.Insert( hall );
        return RedirectToAction("Index");
    }
}
AddHall.cshtml (just checkbox part)

<div class="form-group d-flex flex-wrap justify-content-between align-items-center">
    <label class="checkbox m-0 text-muted">
        <input asp-for="IsUpHall" name="IsUpHall" id="IsUpHall" /> Üst Mekan
        <span></span>
    </label>
</div>



Aucun commentaire:

Enregistrer un commentaire