I have a ASP.NET MVC 4 project with EF and I have a table Orders with a field ShipmentDay varchar(7)/string where I want to save in the database in witch days of the week the order can be shipped : 1000100 for Monday and Friday.
Right now I have a ListBox :
@Html.ListBoxFor(model => model.ShipmentDay, new MultiSelectList(ViewBag.ShipmentDay))
List<string> lbSDay = new List<string>();
ZileLiv.Add("Monday"); ...
public ActionResult Create()
{
ViewBag.lbSDay = lbSDay ;
return View();
}
Q: How can I make a custom multiselect control to select the days of week ?
I'd start out by getting rid of the varchar(7) and storing the shipment days in a single byte with the following weekday values...
Create a html helper extension method to build up a multiselect using those values
to give, e.g.
Calculate if the option should be selected using something like