What don't you understand in the error message ? You can't use CheckBoxFor for an int property.
You should change your model and set
public bool IsActive {get;set;}
Now, there's probably a good reason for it to be an int, but hard to say why with your code...
if IsActive can be only 0 or 1, you should use a ViewModel class, and use a boolean property, which you will map to your class.
public class StudentViewModel
{
public int StudentID { get; set; }
public string Code { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }
}
then when you get your student from your db (in your "GET" action")
something like that (rustic)
public ActionResult StudentEdit(int id) {
var student = getStudentById(id);
var model = new StudentViewModel {
StudentId = student.StudentID,
Code = student.Code,
Description = student.Description,
IsActive = student.IsActive == 1
};
return View(model);
}
Your view should be typed with StudentViewModel
@model StudentViewModel
then in your POST action, reverse
[HttpPost]
public ActionResult StudentEdit(StudentViewModel model) {
var student = getStudentById(model.StudentID);
student.Code = model.Code;
student.Description = model.Description;
student.IsActive = model.IsActive ? 1 : 0;
UpdateStudent(student);
return Redirect...
}
EDIT :
This is a really rustic answer, and I'm sure you could do better.
For that, we would need some more infos :
Are you using Entity Framework (version) ?
If yes, Code first, Database first, model first ?
Which database is behind ?
Can you change something to the database ?
What type has IsActive in database ?