public ActionResult Create(RecurringTask recurringTask, FormCollection collection, ICollection<string> dayOfTheWeek)
I am trying to loop through the dayOfTheWeek (which is a group of checkboxes) and I am trying to find out which one is true so than I can use that to assemble a string ex:Monday, Tuesday, etc.
I am just having trouble finding a way of looping through my collection to do it. I keep getting can't apply == to of type string to bool error.
var days = dayOfTheWeek.ToString();
foreach (string day in dayOfTheWeek)
{
if(day == true)
{
}
}
recurringTask.DaysOfTheWeek = days;
This is what I am thinking on how to do it. But I imagine someone out there has a way better idea than I do. The day == true gives me that string to bool error and its obvious to why its happening, I just don't know how to get around it.
My view is this:
<input type="checkbox" name="dayOfTheWeek" value="Monday" />
<input type="checkbox" name="dayOfTheWeek" value="Tuesday" />
<input type="checkbox" name="dayOfTheWeek" value="Wednesday" />
<input type="checkbox" name="dayOfTheWeek" value="Thursday" />
<input type="checkbox" name="dayOfTheWeek" value="Friday" />
<input type="checkbox" name="dayOfTheWeek" value="Saturday" />
<input type="checkbox" name="dayOfTheWeek" value="Sunday" />
Captionproperty, or itsCheckedproperty? My guess is you aren't checking theCheckedproperty, because if you doif(MyCheckbox.Checked)that works fine.