English 中文(简体)
关键项目没有“观点”项目。
原标题:There is no ViewData item with the key
  • 时间:2009-08-31 09:52:59
  •  标签:

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

最佳回答

你们还需要在《名册》接受方法中确定看法数据,因为如果存在错误,就会回到原来的观点。

祝福

丹麦

或将其列入您的模式: 你们需要改变观点。

问题回答

你的行动必须确定你们的看法。

您的行动

 ViewData["NotificationUsergroups"] = NotificationUsergroups;

一切都应该是神圣的。





相关问题
热门标签