I'm using Visual studio 2013 with C#. I have a simple web page that I want to display radio buttons for a section named Urgency.
The values for this Urgency section are sat in a table named urgency in SQL. I can successfully display these values from the database in the form of the @Html.DropDownListFor.
This is the code I have used for the @Html.DropdownList that works:
@Html.DropDownListFor(model => model.client.Urgency, new SelectList(Model.allUrgencies, "Id", "Urgency", 0), " - Select Urgency -")
I'm trying to convert the @Html.DropDownListFor to a @Html.CheckBoxFor, this is proving to be very difficult and I'm struggling to get this to work.
I have managed to transform the dropdownlist to the following code but this still produces errors.
@Html.CheckBoxFor(model => model.client.Urgency, new SelectList(Model.allU, "Id", "Urgency1"))
These are the errors:
Cannot implicitly convert type 'short?' to 'bool'
Cannot convert lambda expression to delegate type 'System.Func' because some of the return types in the block are not implicitly convertible to the delegate return type.
Here is my list in my Model.
[Display(Name = "Urgency:")]
public List<Urgency> allUrgencies { get; set; }
Here is a screen shot of my database table.
Any suggestions are welcome.