我有一個發佈multiselect的問題,我得到的錯誤: 「有沒有ViewData項與關鍵'NotificationUsergroups'類型'IEnumerable'」。有沒有ViewData項目的關鍵
在控制器中,我有:
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");
}
}
可能是什麼問題?我檢查了拼寫和所有,如果我不運行multiselect列表的作品。
什麼使數據「消失」?
在此先感謝 /M
你是什麼意思「在我有控制器」? – 2009-08-31 10:00:32