모델
public class Admin {
private List<int> _selectedEventIds;
public List<int> SelectedEventIds {
get {
return _selectedEventIds ?? new List<int>();
}
set {
_selectedEventIds = value;
}
}
private List<Events> _eventList;
public MultiSelectList EventList {
get {
return new MultiSelectList(
_listeFonctions,
"EventId", // dataValueField
"EventName" // dataTextField
);
}
}
public Admin() { }
public Admin(List<int> selectedEventIds, List<Events> eventList) {
SelectedEventIds = selectedEventIds;
_eventList = eventList;
}
}
public class Event {
public int EventId { get; set; }
public string EventName { get; set; }
public Event() { }
public Event(int eventId, string eventName) {
EventId = eventId;
EventName = eventName;
}
}
보기
@model Admin
@using(Html.BeginForm()){
@Html.ListBoxFor(admin => admin.SelectedEventIds, Model.EventList)
<input type="submit" value="Save"/>
}
난 당신이 이미 컨트롤러가 추정.