I would like to have a checkbox for my Online_Ballot, where a checkbox contains of candidates where a voter could vote for a specific candidates.
Below is my code.
CandidatesViewModel.cs
public class CandidatesViewModel
{
public IEnumerable<candidates> AvailableCandidates { get;set; }
public IEnumerable<Candidates> SelectedCandidates { get; set; }
public PostedCandidates PostedCandidates { get; set; }
}
public class PostedCandidates
{
public string[] CandidatesId { get; set; }
}
Candidates.cs
public class Candidates
{
public int candidates_info_id { get; set; }
public string candidates_fullname { get; set; }
public object Tags { get; set; }
public bool IsSelected { get; set; }
}
Controller
public ActionResult Votation(PostedCandidates PostedCandidates)
{
return View();
}
View
@Html.CheckBoxListFor(x => x.PostedCandidates.CandidatesId,
x => x.AvailableCandidates,
x => x.candidates_info_id,
x => x.candidates_fullname,
x => x.SelectedCandidates)
But when I tried to run this code, an error is displayed:
'System.Collections.Generic.IEnumerable' does not contain a definition for 'PostedCandidates' and no extension method 'PostedCandidates' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)