I got this error:
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'.
here is my view :
@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>
}
here is controller:
public ActionResult EditCategory(int CategoryID)
{
return PartialView(entity.TBL_CATEGORIES.Select(c=>c.CategoryID==CategoryID).FirstOrDefault());
}
And actionlink:
@Html.ActionLink("update", "EditCategory", "Administrator", new { CategoryID = categories.CategoryID }, new { @class = "openDialog", dialog_id = "EditCategory", dialog_title = "Update Category" })
Thanks.
your select statement is the cause of the problem – its returning the bool – I think you meant the c=>c.CategoryID==CategoryID to either be in a Where or in the FirstOrDefault (depending on your data source – I don’t think EF 4.0 support claues in FirstOrDefault)
try
the Select is intended to Project a result, not be the where clause.