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 SinghPosted Jun 7, 2021, 1:41 PM
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.
Rijwan AnsariPosted Jun 7, 2021, 3:51 PM
Satya KarkiPosted Jun 7, 2021, 3:40 PM