I have a problem with posting a multiselect, I get error: "There is no ViewData item with the key NotificationUsergroups of type IEnumerable ."
在控制器中,我有:
MultiSelectList NotificationUsergroups = new MultiSelectList(Usergroups, "UsergroupID", "UsergroupName", selectedNotificationUsergroupIDs);
ViewData["NotificationUsergroups"] = NotificationUsergroups;
我认为:
<%= Html.ListBox("NotificationUsergroups")%>
在员额行动中:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ObjectEdit([BindAttribute(Include = "BookingObjectID,BookingObjectName,Activated,ActivationStartDate,ActivationEndDate,AvalibleObjects,AvalibleObjectsPerBooking")]BookingObject bookingobject, int[] Objectcategories, int[] NotificationUsergroups, int[] CancellationUsergroups)
{
if (ModelState.IsValid)
{
try
{
_bs.SaveBookingObject(bookingobject);
if (NotificationUsergroups != null)
_bs.SaveNotificationUsergroups(bookingobject.BookingObjectID, NotificationUsergroups);
return View("CreateObject", new BookingObjectsAdminEditViewModel { BookingObject = bookingobject });
}
catch {
ModelState.AddModelError("SomeError", "errrrrrrrrror");
}
}
什么可能是错误的? 我检查了拼写和所有的工作,如果I dont带着多语名单进行。
数据“消失”是什么?
Thanks in advance /M