I successfully save the value for the database (header value) when pasting, but when I render the same view in edit mode, then the header field should contain the selected value, but in my case no value is selected from the drop-down list .. dont I know why I get a drop-down list with nothing selected, while the header field contains the saved value (on the backend).
@Html.DropDownListFor(model => model.title, new SelectList(Model.titles, "Value", "Text"),"-Select-")
values for the header
titles = new SelectList(ListItem.getValues().ToList(), "Value", "Text").ToList();
GetValue function
public static List<TextValue> getValues() { List<TextValue> titles= new List<TextValue>(); TextValue T= new TextValue(); T.Value = "Mr"; T.Text = "Mr"; titles.Add(T); T= new TextValue(); T.Value = "Mrs"; T.Text ="Mrs"; titles.Add(T); T= new TextValue(); T.Value = "Miss"; T.Text = "Miss"; titles.Add(T); T= new TextValue(); T.Value ="Other"; T.Text = "Other"; titles.Add(T); return titles; }
source share