我得到這個錯誤:傳入字典的模型項目的類型是'System.Boolean'?
The model item passed into the dictionary is of type 'System.Boolean', but this dictionary requires a model item of type 'DunyaYazilim.Models.TBL_CATEGORIES'.
這裏是我的看法:
@model DunyaYazilim.Models.TBL_CATEGORIES
@{
ViewBag.Title = "EditCategory";
}
@using (Html.BeginForm((string)ViewBag.FormAction, "Administrator"))
{
<div>
<div>Category Name</div>
<div>@Html.TextBoxFor(m => m.Name)</div>
<input type="submit" value="Submit" />
</div>
}
這裏是控制器:
public ActionResult EditCategory(int CategoryID)
{
return PartialView(entity.TBL_CATEGORIES.Select(c=>c.CategoryID==CategoryID).FirstOrDefault());
}
而且ActionLink的:
@Html.ActionLink("update", "EditCategory", "Administrator", new { CategoryID = categories.CategoryID }, new { @class = "openDialog", dialog_id = "EditCategory", dialog_title = "Update Category" })
感謝。
檢查entity.TBL_CATEGORIES.Select(C => c.CategoryID == CategoryI)語句和makesure你selecing幾個值的不只是一個,可能是布爾 –