3
Answers

mvc checkboxes selection

Help Needed

Help Needed

8y
354
1

Hi

 

 I am working with checkboxes in MVC.I have a table with one clolumn as "bit" type.The following code giving me error

 [HttpPost]
 public string Index(IEnumerable<City> cities) 
{ 
if (cities.Count(x => x.Chosen) == 0)
 {
 return "You did not select any city"; 
}

Chosen is a bit type here. and when i am trying to build it says "

 

 Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?) 

Answers (3)