I have a model that looks something like this:
public class SampleModel
{
public static SampleModel Create()
{
return new SampleModel
{
Boolean = true,
Colors = new SelectList(new[] { "Red", "Green", "Blue" }, "Green")
};
}
public bool Boolean { get; set; }
public SelectList Colors { get; set; }
}
I let ASP.NET MVC automatically align properties using Html.DisplayForModel()for my presentation of information and Html.EditorForModel()for my kind of editing.
Results:
Editing works great. Colorsappears as a menu with three items (red, green, and blue), and green is selected by default.
However, to represent the information, I get "False True False", which is apparently a list of values IsSelectedfor each menu item. I donβt want that. I would like it to just display Green.
, UpdateModel(sampleModel) , : " ". , -, , Colors SelectList, SelectList , .
, , , , , , , , .
:
Colors "", (, "" ) ""?- " " ,
SelectList? - /ViewModel ,
ColorId Colors, , Details, , , , Color . , LinqToSql (SqlMetal) .