Hi
I have IsActive = Bit type in Sql . In input form i have below code
On Controller it gives message - [0] = "The value 'Y' is not valid for IsActive."
[HttpPost]
public ActionResult CreateEdit(Product objProduct)
{
if (ModelState.IsValid)
{
dbProduct.Add(objProduct);
}
else
{
var query = from state in ModelState.Values
from error in state.Errors
select error.ErrorMessage;
var errors = query.ToArray();
}
return RedirectToAction("Index");
}
*********************************************************
[Required]
[Range(minimum: 1, maximum: 1)]
public bool IsActive { get; set; }
Thanks

Sachin SinghRank #66 · 26.2K reputationPosted Jun 7, 2021, 9:41 AM EDT
If it is a bit then why are you taking yes/no, for the user's perspective too it is not good instead use the checkbox.
if i am a user of your app i will never like to enter yes or no, but i will definitely like to check or uncheck the checkbox.
Satya KarkiRank #78 · 24.6K reputationPosted Jun 7, 2021, 11:40 AM EDT
Rijwan AnsariRank #82 · 24.2K reputationPosted Jun 7, 2021, 11:51 AM EDT